jhomlala / catcher

Flutter error catching & handling plugin. Handles and reports exceptions in your app!
Apache License 2.0
784 stars 175 forks source link

[BUG] It does not catch SYNCHRONOUS ERRORS #195

Closed topperspal closed 2 years ago

topperspal commented 2 years ago

Just try to remove async keyword from the method below ( given in first example of the readme ) and it will not catch the error

BEFORE

generateError() async {
    throw "Test exception";
 }

AFTER

generateError() {
    throw "Test exception";
 }
rcsousa14 commented 2 years ago

Yes I notice this too. How is it going for the bug fix?

mikeesouth commented 2 years ago

I can also reproduce this by following the simple instructions from @topperspal. I do have the opposite in my app though, synchronous exceptions are caught but if I add async, it's not caught. I'm using latest version of catcher in both cases (0.6.8) and same Flutter installation (stable 2.5.3).

I found this bug report about async exceptions: https://github.com/jhomlala/catcher/issues/108 that discussed adding WidgetsFlutterBinding.ensureInitialized(); before catcher initialization to get async exceptions to work. It's even a constructor parameter to help out with this: ensureInitialized: true but this parameter is not set in the example. The example does not call WidgetsFlutterBinding.ensureInitialized(); but async exceptions are still caught. As @topperspal reported, the example does not catch synchronous errors but I suspect that this is related to #108.

Could it be that something in catcher initialization chain puts us in the case of either catching synchronous exceptions but not async ones, or the opposite, catching async but not sync ones? Could #108 help us understand this bug better?

jhomlala commented 2 years ago

Please use search function next time: https://github.com/jhomlala/catcher/issues/75#issuecomment-615720375

@mikeesouth If problem still occurs in release mode, please create ticket with reproducible example.