Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breaking on your own exceptions in IntelliJ

See this question on how to break on any exceptions.

I'm getting a million exceptions on startup. I've tried ignoring ClassNotFoundException, but it's no good, the IDE still seems to break on these (and other) exceptions.

So .. what's a decent configuration for this to catch only real exceptions caught from user code? (Ignore also any exception in jUnit, if applicable)

like image 668
ripper234 Avatar asked Jul 08 '09 18:07

ripper234


People also ask

How do I create an exception breakpoint in IntelliJ?

Set exception breakpointsin the left part of the Debug tool window or press Ctrl+Shift+F8 . Depending on the type of the exception: If you want to suspend the program when any instance of Throwable is thrown, check Any Exception under Java Exceptions.

What is F8 in IntelliJ?

Step Over (F8) lets you execute a line of code and move on to the next line. As you step through the code, you'll see the value of the variables next to the code in the editor window. These values are also visible in the Variables pane in the Debug window.

How do I throw an exception in IntelliJ?

Throw an exception Make sure the current method is selected on the Frames tab, then right-click anywhere in the tab and select Throw Exception. Create the exception (this can be any Throwable including Error and checked exceptions that are not handled by the method).


2 Answers

As mentioned by the other posters, Class Filters are the way to do this.

Specifically, you could add the package names for what you consider "your code" as a class filter. The syntax is a little opaque, but using a simple wildcard filter like:

com.whatever.package.*

sounds like it it will work for you. IntelliJ will break on any exception in any class in any package under here. You can of course define multiple wildcard filters if your code is in more than one place.

like image 96
serg10 Avatar answered Sep 17 '22 12:09

serg10


I was just messing with this earlier. Two ways to go:

1) Configure it to explicitly catch your exception, not "any exception" - if it's something like RuntimeException, this may not be filter-y enough. 2) Use the class results filter - this for whatever reason did NOT work for me. Ever.

like image 40
James Avatar answered Sep 17 '22 12:09

James