Complete
over 4 years ago

WERETECH-6805

This was addressed in CIQ 3.1.1.

How to debug an unhandled exception

On a fresh Eclipse install on macOS High Sierra with recommended settings (several example apps do build and run), I can't seem to get a strack trace after an unhandled exception (aka app crash). Without that information, it's pretty much impossible to debug an app, so I guess I just missed some setting.

What did I miss?
Former Member
Former Member
Parents
  • The exception string and stack trace should get printed as the application teardown happens. I'd be interested to see a test case that demonstrates the problem so we can get a look and make a fix if necessary. As for how to debug it, you have a few options. You can debug the program under eclipse and set breakpoints at various places and step through the code as is necessary. The classic printf debugger is often sufficient for most needs, but it isn't ideal as it takes time (sprinkle print calls throughout the code and then run it, find the area where the problem is, remove print code from other areas and add more in the problem area until you find the exact line), or catch the exception and log the result... try { // code that might throw an exception } catch (ex) { Toybox.System.println(ex.getErrorMessage()); ex.printStackTrace(); // rethrow if you want to let it crash throw ex; } Travis
Comment
  • The exception string and stack trace should get printed as the application teardown happens. I'd be interested to see a test case that demonstrates the problem so we can get a look and make a fix if necessary. As for how to debug it, you have a few options. You can debug the program under eclipse and set breakpoints at various places and step through the code as is necessary. The classic printf debugger is often sufficient for most needs, but it isn't ideal as it takes time (sprinkle print calls throughout the code and then run it, find the area where the problem is, remove print code from other areas and add more in the problem area until you find the exact line), or catch the exception and log the result... try { // code that might throw an exception } catch (ex) { Toybox.System.println(ex.getErrorMessage()); ex.printStackTrace(); // rethrow if you want to let it crash throw ex; } Travis
Children
No Data