0

Is there a way to configure an IntelliJ Java exception breakpoint so that it only triggers when the bottom class in the stack trace is a specific class? For example, with the stack trace below, I'd like to break only when the bottom line contains the class ComputeLCAInBinaryTreeSpec.

java.lang.IndexOutOfBoundsException: Index: 4, Size: 4

    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at com.common.BinaryTreeNode.buildBinaryTree(BinaryTreeNode.groovy:62)
    at com.common.BinaryTreeNode.buildBinaryTree(BinaryTreeNode.groovy:76)
    at com.common.BinaryTreeNode.buildBinaryTrees_closure1(BinaryTreeNode.groovy:53)
    at groovy.lang.Closure.call(Closure.java:426)
    at com.common.BinaryTreeNode.buildBinaryTrees(BinaryTreeNode.groovy:51)
    at com.elementsofprogramminginterviews.binarytrees.ComputeLCAInBinaryTreeSpec.computes LCA of two nodes of a binary tree_closure1(ComputeLCAInBinaryTreeSpec.groovy:65)
    at groovy.lang.Closure.call(Closure.java:426)
    at groovy.lang.Closure.call(Closure.java:442)
    at com.elementsofprogramminginterviews.binarytrees.ComputeLCAInBinaryTreeSpec.computes LCA of two nodes of a binary tree(ComputeLCAInBinaryTreeSpec.groovy:47)
Julian A.
  • 10,928
  • 16
  • 67
  • 107
  • 1
    You may be able to leverage exception breakpoints. I've never personally used them but you can set conditions as well as filters. See https://www.jetbrains.com/help/idea/2017.1/creating-exception-breakpoints.html for details – Robert H May 23 '17 at 16:39

1 Answers1

5

You should be able use breaking on any exception with conditions to achieve this. Similar to my answer to this other question (maybe it's of interest to someone), just get the stacktrace, and check if it contains your class (or if it's the first one in the hierarchy):

condition

Morfic
  • 15,178
  • 3
  • 51
  • 61