Closed suda closed 10 years ago
Ahh, very interesting. Never crossed my mind that an exception could get thrown in a background thread. This is fun. Be back with a fix in 30 minutes.
@suda Sad day, this needs a Context :-/ Are you calling Sentry.catpureEvent() manually? Because I don't think this error should be able to come from a force closed uncaught exception.
Yes, it's captured in try ... catch block with Sentry.captureException(e); Can't context be stored in static instance of Sentry class? It is passed to initializer.
I could store the context in the initializer but I would prefer not. Do you have access to the context from where your calling Sentry.captureException?
I did some research (tweeted Jake Wharton) on if its bad to keep the application context and in a single and its not. So I will look into adding that. I have some client work I need to get done before I can do this so I would use this solution for now.
http://stackoverflow.com/questions/11123621/running-code-in-main-thread-from-another-thread
I don't have access to context where I capture exception, so only way would be to store it in sentry. Instead of using context to get main looper, is it possible to use Looper.getMainLooper() ? I'll try to hack it until you fix it :)
@suda Made a fix for this if you want to review - https://github.com/joshdholtz/Sentry-Android/pull/9
When a exception is being caught on thread other than main (i.e. AsyncTask), sentry throws its own exception:
It seems to be an issue with your Protocol library (handler not initiated with Looper.getMainLooper()).