Fixed #646 sending background exception to the global UncaughtExceptionHandler#763
Conversation
…al UncaughtExceptionHandler
|
Tested in my project where I set a custom exception handler (like ACRA and ACRA-like libraries do) and it works like a charm. The runtime exceptions thrown in I also tested without custom exception handler, which then is the android one The only caveat is if for obscure reason the default exception handler is set to null, then the app doesn't crash and no exception is logged. But in this case, uncaught exception in the main thread doesn't crash the app too (but a warning is logged), so maybe we can ignore that case. |
|
So for me it's a BIG 👍 ! |
|
Everything seems to work fine. Great job here 👍 But, while I was testing this PR, I tried to write something like this : @Click
void buttonCrashableCatchClicked() {
try {
crashableBackground();
} catch (RuntimeException e) {
Log.d("SANDBOX", "Crashable background crashed correctly");
}
}
@Background
void crashableBackground() {
Log.d("SANDBOX", "Crashable background");
throw new RuntimeException("Boom");
}Of course, this doesn't work, because the exception is thrown to another thread. But I'm sure we'll have lots of issues about it. So we MUST update the |
Fixed #646 sending background exception to the global UncaughtExceptionHandler
|
Thanks for PR 👍 |
|
I'm not sure how to use this. In my @background annotated method, I call Thread.setDefaultUncaughtExceptionHandler and pass in my class. But it never seems to be called. Am I misunderstanding? By the way, I am working off the latest 3.0-SNAPSHOT from the Sonatype repo -- does that have this in it? |
|
Could you give us some code ? I tested again on a sandbox and it works fine. For information, I have something like this : @EActivity(R.layout.activity_background)
public class BackgroundActivity extends Activity implements UncaughtExceptionHandler {
@Click
void buttonCrashableCatchClicked() {
Thread.setDefaultUncaughtExceptionHandler(this);
crashableBackground();
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Log.d("SANDBOX", "crashable Background crashed correctly");
}
}Note: You don't have to call |
|
Hmm, it seems to be resolved now. I even reverted to the code I was working with yesterday, but it's still working as expected. Only thing I can thing of is to blame it on is IntelliJ using an outdated SNAPSHOT jar or something? I did rebuild the project in between, so maybe that was it. Thanks for the help! |
See #646 and #727