2

enter image description hereI'm new to Java and using InteliJ Idea community edition. I previously used Visual Studio with C#, where I could select if exception would break (and wait "as breakpoint") on my code only.

meaning I could choose to avoid seeing exceptions of 3rd party libraries, until (and only if) they affect my code.

At InteliJ Idea I could not find that option... Only "stop at all exceptions" which is mostly to verbose for me

user355289
  • 1,100
  • 2
  • 13
  • 23
  • 3
    In the Breakpoints view (ctrl+shift+a for searching in actions->breakpoints) you should be able to click on a plus sign to add 'Java Exception Breakpoints' and there you can choose a type. (This is on intellij ultimate though, but I would assume it's also available in community.) (See https://www.jetbrains.com/help/idea/using-breakpoints.html). – Alowaniak Jul 22 '19 at 16:22
  • I added a picture to the question. I don't know the type of the exception I want to catch, or the class that throws or catches it. Just that I want the code to break at the first line of code that's mine, showing only my code stack. – user355289 Jul 22 '19 at 20:27

1 Answers1

1
  1. Open "View Breakpoints". enter image description here

  2. Add "Java Exception Breakpoints".

2

  1. Find the exception you want to keep track of.

    3

  2. Apply filters

enter image description here

There is no handy option to exclude/include the whole scope (e.g. your current project scope), but you may write a class pattern to filter out individual packages (e.g. -java.* -sun.*).

You also may play with the condition for hitting a breakpoint. It has the context of an exception itself (this) and, thus, this.getStackTrace() which can be used to determine what path, origin (getStackTrace()[0]), or destination (getStackTrace()[getStackTrace().length - 1]) to reject. It's not the best solution, but, at least, an option to consider.

Andrew Tobilko
  • 48,120
  • 14
  • 91
  • 142