Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This bit of code is never going to work.</p> <p>An uncaught exception handler is called <em>after</em> a thread has terminated due to an exception that was not caught. If you then attempt to re-throw the exception, there will be nothing else to catch it. </p> <ul> <li><p>If you want to have your re-thrown exception handled in the normal, you have to do the logging further up the stack.</p></li> <li><p>The only other option you have is to <em>explicitly</em> chain to another <code>UncaughtExceptionHandler</code>.</p></li> </ul> <hr> <p>I <em>suspect</em> that the freeze is you are experiencing is a direct consequence of the current thread dying.</p> <hr> <p><strong>FOLLOWUP:</strong></p> <blockquote> <p>... is there some other way in Android to intercept exceptions at a global level, without using Thread.setDefaultUncaughtExceptionHandler? </p> </blockquote> <p>AFAIK, no.</p> <blockquote> <p>Or how would the chaining look like?</p> </blockquote> <p>Something like this:</p> <pre><code>public void uncaughtException(Thread thread, final Throwable ex) { // do report ... getSomeOtherHandler(...).uncaughtException(thread, ex); } </code></pre> <p>Or, since ThreadGroup implements <code>UncaughtExceptionHandler</code>, ...</p> <pre><code>public void uncaughtException(Thread thread, final Throwable ex) { // do report ... thread.getThreadGoup().uncaughtException(thread, ex); } </code></pre> <p>Basically, you just call some other handler. It's not rocket science.</p> <p>But note that you can't catch and recover from an exception in the "normal" way once you've landed in one of these handlers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload