代码之家  ›  专栏  ›  技术社区  ›  Steve Bennett

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

  •  1
  • Steve Bennett  · 技术社区  · 8 年前

    我正在用这种结构执行一些代码:

    try {
      doSomething();
    } finally {
      doAnotherThing();
      // more nested try statements down here
    } 
    

    某个地方正在触发一个异常,但我不知道它是否在 doSomething() . 因为代码转到 doAnotherThing() 不管是否触发了异常,这都不会告诉我什么。

    触发异常时是否有可视指示?(智能14.1.7)。

    1 回复  |  直到 8 年前
        1
  •  2
  •   Alex Taylor    8 年前

    try Breakpoints window

    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
        }
    }