-
Notifications
You must be signed in to change notification settings - Fork 520
Conversation
I like the concept, and it seems like a fairly portable API to have everywhere. My one concern, however, is that |
@richardjrossiii The fact that it runs on a GC thread doesn't make it useless. It might prevent that handler from directly calling UI methods, but it could still log the error someplace useful. Also the default handler could fire off a new Task to deal with the error like so:
|
This looks interesting! I want to play around with this to see how this plays out in different environments. If it works well, we'd also want this configurable and off by default to not be a breaking change and so developers can turn it off in production environments. |
To turn it off by default, we could just add a static field and getUnobservedExceptionHandler() and setUnobservedExceptionHandler() methods. the default would just eat the exception. Then use that instead of Thread.getDefaultUncaughExceptionHandler(). |
df38413
to
b1e4be6
Compare
@stefanrusek updated the pull request. |
@grantland I made it configurable and added a test. |
FYI, I'll be without a computer until December and won't be able to take a look at this until then. Hope that's ok and sorry! |
@grantland ping |
Finally got around to playing around with it and it's awesome! Thanks for updating it so that it doesn't throw on the uncaught exception handler by default. @hallucinogen mind taking a look at the API and giving a second opinion? |
ueh.unobservedException(faultedTask, new UnobservedTaskException(faultedTask.getError())); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one small edit: we should be using try { ... } finally { super.finalize() }
here
b1e4be6
to
ab173ef
Compare
@stefanrusek updated the pull request. |
* finalized. If it is finalized with a task, then the uncaught exception handler is exected | ||
* with an UnobservedTaskException. | ||
*/ | ||
public class UnobservedErrorNotifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want to make this package private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
* @param t the task | ||
* @param e the exception | ||
*/ | ||
void unobservedException(Task<?> t, UnobservedTaskException e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right. In Java isn't this usually in some form of onUnobservedException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently matches Thread.UncaughtExceptionHandler
's pattern: https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm then
Last nit is to hide |
ab173ef
to
c1bec34
Compare
@stefanrusek updated the pull request. |
This defers the actual finalization handling to a secondary class. Additionally if any of the continuations immediately observe the error, then no additional finalization logic is performed. If no unobserved exception handler is set, then no finalization processing takes place. Fixes BoltsFramework#48
@grantland updated visibility |
Monitor for unobserved errors
Thanks for you're awesome contribution! As a thank you, wed like to send you some Parse swag. If you're interested, send me your mailing address and t-shirt size to my email address on my profile page. |
This defers the actual finalization handling to a secondary class.
Additionally if any of the continuations immediately observe the error,
then no additional finalization logic is performed.
Fixes #48