Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何判断在IntelliJ中调试时是否触发了Java异常?_Java_Debugging_Exception_Intellij Idea - Fatal编程技术网

如何判断在IntelliJ中调试时是否触发了Java异常?

如何判断在IntelliJ中调试时是否触发了Java异常?,java,debugging,exception,intellij-idea,Java,Debugging,Exception,Intellij Idea,我正在逐步浏览一些具有这种结构的代码: try { doSomething(); } finally { doAnotherThing(); // more nested try statements down here } 某个地方触发了异常,但我不知道它是否在doSomething()中。因为不管是否触发了异常,代码都会转到doAnotherThing(),这不会告诉我任何情况 当触发异常时,是否有视觉指示?(IntelliJ 14.1.7)。在运行->断点菜单项下查看。您可

我正在逐步浏览一些具有这种结构的代码:

try {
  doSomething();
} finally {
  doAnotherThing();
  // more nested try statements down here
} 
某个地方触发了异常,但我不知道它是否在
doSomething()
中。因为不管是否触发了异常,代码都会转到
doAnotherThing()
,这不会告诉我任何情况


当触发异常时,是否有视觉指示?(IntelliJ 14.1.7)。

在运行->断点菜单项下查看。您可以添加(使用“+”按钮),“Java异常断点”并指定要中断的异常类型。添加后,您可以在
try
块内的另一个断点上使用“在命中选定断点之前禁用”,将其限制为您关心的代码。包含许多有用的控件,用于控制何时触发断点

如果需要知道是否引发了异常,则需要将其存储在代码中:

Throwable thrown = null; 
try {   
    //Do very important work here
} catch (ImportantException e) {
    thrown = e;
    throw e;
} finally {   
    if (thrown != null) {
        //We arrived in the finally block due to an exception
    }
}

只是想知道:为什么你又在使用一个像岁的intellij版本?这是我有许可证的版本。谢谢,这非常有用。是否有一种直接的方式来查看“当前正在处理异常”。不幸的是,没有。最接近的方法是遵循中列出的方法