NetBeans and stop/break on all Exceptions? NetBeans and stop/break on all Exceptions? android android

NetBeans and stop/break on all Exceptions?


I have this problem when I use netbeans too. To get the exception message, I use try-and-catch. In the catch() statement, call a function that contains some code and put a breakpoint on it. Then when the exception is given your breakpoint in the catch statement will be called and you can read the information (error message, stack, etc.) from the Exception obect.

try{    // Doing something here}catch (Exception e1){    // This is called when an exception occurs    doSomething();   /// Put breakpoint here}

UPDATE:

I am not sure if this will work for android but you could try entering a "New Breakpoint". When entering a new breakpoint to break on an exception, you need to know theexact package/class exception name. For example, if you want to catch aNullPointerException, then you go to Debug >> New Breakpoint to create a New Breakpoint and enterjava.lang.NullPointerException into the Exception Class Name field in theBreakpoint Properties dialog. Choose whether to break on caught, uncaught or both, exceptions and it will hit a breakpoint if that type of exception ever occurs in the class/project.


I had such behavior where I had my source file that generated the exception NOT in "default package". When I moved everything to "default package" it started working fine and stop on exception automatically.


This answer actually also answers this question: https://stackoverflow.com/a/2671390/415551

To quote user Finbarr:

Go to debug > New Breakpoint (alternatively CTRL+SHIFT+F8). Change the breakpoint type to Exception in the top right hand drop down menu. Type java.lang.NullPointerException in the Exception class field. Choose whether to break on caught, uncaught or both.

Debug your code and watch the glorious auto breakpoint when the Exception is thrown.

Simply change java.lang.NullPointerException to java.lang.Exception to break on any error.