Eclipse is one of the most popular integrated development environment for Java programming language. It is full of features to help us make Java development and debugging easy and fun.
When it comes to debugging you may already be familiar with break points (execution stops every time) and conditional break points (execution stops only if a condition is true).
When it comes to debugging an exception, the general practice followed is to print the stack trace when an exception occurs, identify the line from where exception is thrown, put a break point on that line and debug. Eclipse provides a feature to help debug the exceptions more efficiently. Instead of going through above cycle multiple times, it is possible to suspend the execution of a thread when an exception is generated by specifying an exception break point. We can set the exception break point by clicking on Add Java Exception Breakpoint in the break point view as shown below.
In the opened pop-up, we can specify the exception on which we want to suspend the execution.
We can also specify weather we want to suspend the thread only when this exception is caught (using a catch) or only when this exception is not caught or both. Once the exception break point is set, eclipse will suspend the execution whenever that exception is generated from anywhere in the application code. We can also specify filters to apply exception break point to a set of packages or classes only.
Exception break point is not widely known feature of eclipse. But it can come very handy while debugging exceptions.