0

As I discussed in another post (Restore stack trace from string) I restore an exception from a database. I want to report this exception to the Android developer console - but how can I do this?

When the following code is executed, the user is requested to send the exception to the console (the dialog I want to see):

String test = null;
int lenght = test.length;

If I add "throw new Exception();", I always have to add "throws Exception" to the method signature, so it will never end up to report it to the developer console.

Does anyone have an idea?

  • The null pointer exception (from your example) is an unchecked exception (exceptions which don't require catching or updates to method signature). You can always throw a runtime exception (the unchecked superclass) if you want: `throw new RuntimeException("myerror")`. Look into unchecked exceptions for more info. See https://stackoverflow.com/a/27763869/2711811. Ofcourse this would terminate your app - and this appears to be what you want to force the dev console report? You can also extend the RuntimeException with your custom unchecked exception. –  Feb 28 '19 at 10:46
  • This was exactly I was looking for - thank you very much!!! My question is solved! – Gerrit Humberg Feb 28 '19 at 13:17

0 Answers0