Java 抛出异常时中断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3066199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Break when exception is thrown
提问by keithwarren7
Visual Studio has an option to break automatically into the debugger when an unhandled exception is thrown, does Eclipse have similar functionality?
Visual Studio 有一个选项可以在抛出未处理的异常时自动进入调试器,Eclipse 是否有类似的功能?
采纳答案by VonC
You are able to define the precise list of Exception you want to have a breakpoint on, even if those exceptions are uncaught (which should be the equivalent of "unhandled
")
您可以定义要在其上设置断点的精确异常列表,即使这些异常未被捕获(这应该相当于“ unhandled
”)
回答by Carles Barrobés
Go to the breakpoints window, there's a button that looks like J!, there you can set breakpoints for Java exceptions, either caught or uncaught. You can reference classes or use pattern matchers for exception names.
转到断点窗口,有一个看起来像 J! 的按钮,您可以在那里为 Java 异常设置断点,无论是捕获的还是未捕获的。您可以为异常名称引用类或使用模式匹配器。
Also, under Window -> Preferences, Select Java -> Debug and there's a checkbox to tell the debugger to break on uncaught exceptions
此外,在 Window -> Preferences 下,选择 Java -> Debug 并且有一个复选框告诉调试器中断未捕获的异常