如何设置Eclipse在线上停止发生异常? [英] How do I setup Eclipse to stop on the line an exception occurred?

查看:164
本文介绍了如何设置Eclipse在线上停止发生异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置Eclipse在发生异常时停止。

How can I setup Eclipse to stop at the point an exception occurred.

我有一个Eclipse断点设置来中断异常。在下面的代码示例中,我遇到的问题是Eclipse试图打开Integer源代码。在我的代码示例中显示的点上有没有什么办法让调试器中断?如果我向下移动堆栈跟踪,我将得到这一行,如果没有Source not Found窗口出现,有办法可以做到这一点。

I have an Eclipse breakpoint setup to break on an exception. In the code example below, the problem I'm having is Eclipse tries to open the Integer source code. Is there any way to just have debugger break at the point shown in my code example? If I move down the stack trace, I will get to this line, it'd be nice if there's a way to do this without the "Source not found" window coming up.

这可以在Visual Studio中完成,所以它让我疯狂无法在Eclipse中找到一种方法。

This can be done in Visual Studio, so it's driving me crazy not being able to find a way to do this in Eclipse.

package com.test;

public class QuickTest
{
  public static void main(String[] args)
  {
    try
    {
        test();
    }
    catch(NumberFormatException e)
    {
        System.out.println(e.getMessage());
    }
 }

  private static void test()
  {
    String str = "notAnumber";

    Integer.parseInt(str);//<----I want debugger to stop here
  }
}

推荐答案

我不知道如何到达那里,但我只是这样做:

I'm not sure how else to get there, but I just do:

Window -> Show View -> Breakpoints

在该选项卡中有一个J!这可以让你为异常设置断点。

And in that tab there is a "J!" that lets you set breakpoints on exceptions.

这篇关于如何设置Eclipse在线上停止发生异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆