Adding an Exception

Using the Debugger's Exceptions tab, you can instruct the Debugger to handle exceptions generated in your code. An exception is a signal that indicates some type of condition has occurred.

To add an exception to your code:

  1. Open the Exceptions tab in the Debugger.

  2. Enter the class name of the exception in the Exception text field.

    For example, java.lang.ThreadDeath throws an exception when the thread terminates.

  3. Click the Add button.

    The Java WorkShop adds the exception at the top of the scrolling list.

The WorkShop supports three types of exception settings.

Break on uncaught
This setting is the default. A Java program can write try statements to programmatically catch and recover from exceptions. Some exceptions are programming errors (for example, NullPointerException) that you don't normally catch in this way.

By default, the Debugger allows a program written to catch and recover from certain exceptions and to continue to operate correctly without stopping. If, you have no recovery code of your own, as in a NullPointerException, Java simply prints a dump of the exception and stops your program. The Debugger, however, stops your program and treats it as if you had hit a breakpoint.

Break always
If you set an exception to "break always," the exception is treated like a breakpoint even if you have recovery code in your program.

Ignore
If you set an exception to "ignore," then the Debugger does not intervene; you will get the same behavior as you would if you were running the program without the debugger.

You can change an exception's setting by selecting the exception and then clicking the button of the desired setting.


See also:

Exceptions Tab