views:

31

answers:

1

I find the force close Report option very useful as a developer- the stack trace is really useful to see and I've been able to solve many bugs by using it.

However, there are places in my app where (quite rightly) I've used a try/catch statement to handle Exceptions. The problem being, that this prevents a force close and so I can't get the data of the error, which would be helpful for bug fixing or even just giving better error messages. Is there any way to report an Exception which has been handled?

And which version of Android did the Report option come about in?

A: 

If you handle the exception yourself, why don't you call a function to report it?

try {
   [your code]
} catch (BadCodeException e) {
   [handle error]
   MyErrorHandler.ReportError(e);
}

And then

void ReportError(Exception e) {
   // Take the stack trace, error message, and what ever else comes to your mind,
   // and mail it or store it somewhere or whatever.
}

As for your other question - I believe it was Android 2.0. Then, Android 2.2 introduced stack traces in ANR situations (application not responding).

Other than that, once an execption is handled, it's handled. You could choose not to handle it and give your thread an unhandled exception handler, but that will make it hard to recover from the error.

EboMike
Excellent, thanks for all the info! I'm fairly new to using the web in my app, and the only way I could think of sending myself the information is by email... any suggestions?
Espiandev
I would definitely recommend sending it by email, and only after getting the user's consent. Quietly sending it any other way would make people very angry. It's also very easy - just create a String with all the info and use the ACTION_SENDTO intent with your email address, this will use the user's favorite email client and give them a chance to look over the data being sent.
EboMike