title: In a Java debugger, how to ignore exceptions never passing through my code
body: <p><em>I'm currently using IntelliJ IDEA for Java development, but I'm also interested in answers targeting other IDEs or general concepts for debugging Java code. Because this is a feature I've missed in a number of IDEs, I'm unsure if I've missed a workflow concept when transferring my debug habits from other languages.</em></p>
  
  <p>Let's say I'm writing some code in <code>myapp.*</code> while using framework classes from <code>somelib.*</code>. A typical stack trace may start in either package and may switch several times between them. Let's also say I'm debugging under the assumption that there are bugs in <em>my code</em> and that there aren't any in the <em>library code</em>. An example stack trace (showing only class names):</p>
  
  <pre><code>somelib.D (current stack frame)
  somelib.C
  myapp.Y
  myapp.X
  somelib.B
  somelib.A
  </code></pre>
  
  <p>Normally, I'm not interested in the following types of exceptions and do not want the debugger to break on them:</p>
  
  <ul>
  <li><p>Thrown in <code>somelib.B</code> and caught in <code>somelib.A</code>. Either the library code is throwing exceptions to handle problematic state inside the library or to stop the application. In the latter case, I'm only interested in the exception message which hopefully tells me what's wrong.</p></li>
  <li><p>Thrown in <code>somelib.D</code> and caught in <code>somelib.C</code>. The library code may use exceptions as a form of logic where a certain action is tried and an alternative route is taken in the case of a problem or where my code is notified by the problem by other means (e.g. returning a null reference where appropriate).</p></li>
  </ul>
  
  <p>Types of exceptions I am interested in:</p>
  
  <ul>
  <li><p>Thrown in <code>somelib.C</code> or <code>somelib.D</code> and not caught in <code>somelib.C</code> or <code>somelib.D</code>. Here I want the debugger to break on the line in <code>myapp.Y</code> where I call the code from <code>somelib.C</code>.</p></li>
  <li><p>Thrown in <code>myapp.X</code> or <code>myapp.Y</code>, either caught or uncaught. Here I want the debugger to break on the line the exception is thrown.</p></li>
  </ul>
  
  <p>IntelliJ IDEA gives me the options to select wether I want to break on caught or uncaught exceptions, or both and to restrict the location where the exception is thrown to a set of classes. These options don't help much as I normally want to <strong>break on any exception, wether caught or uncaught, as long as code I've written is between the place it's thrown and the place it's caught</strong>, eventually.</p>