Eclipse Conditional-Breakpoint. How to check if exception occurs?

こ雲淡風輕ζ 提交于 2019-12-01 06:09:28

问题


I have this function:

public static FradId readFradId(DataInput pIn) throws IOException {
    Integer lMainId = Integer.valueOf(pIn.readInt());
    Integer lReferenceId = Integer.valueOf(pIn.readInt());
    String lShortname = pIn.readUTF();
    return new FradId(lMainId,lReferenceId,lShortname);
  }

I got a breakpoint at this line:

String lShortname = pIn.readUTF();

my problem is in some cases the function readUTF throws a RuntimeException. The application executes the function more than 100 times so it is very difficult for me finding the problem.

my question: is there a way to catch that exception with a breakpoint condition? I already use that conditions with easy boolean conditions, but I dont know how to stop in that line when a exception is thrown.

Thx in advance

Stefan


回答1:


Yes there is a option called "exception breakpoint"
Open Breakpoint view, click on j! option and add desired exception




回答2:


I think you need Java Exception Break Point

In you eclipse open the 'Add Java Exception Breakpoint...' from Run Menu. You can chose the exception for which you need to have the breakpoint.

Run -> Add Java Exception Breakpoint...



回答3:


did you try something similar?

public static FradId readFradId(DataInput pIn) throws IOException {
    Integer lMainId = Integer.valueOf(pIn.readInt());
    Integer lReferenceId = Integer.valueOf(pIn.readInt());
    try{
        String lShortname = pIn.readUTF();
    }catch(Exception e){
       //need a breakpoint here.
    }
    return new FradId(lMainId,lReferenceId,lShortname);
}


来源:https://stackoverflow.com/questions/15758519/eclipse-conditional-breakpoint-how-to-check-if-exception-occurs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!