如何忽略Eclipse中未捕获的异常的特定类型? [英] How to ignore specific type of uncaught exception in Eclipse?

查看:61
本文介绍了如何忽略Eclipse中未捕获的异常的特定类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java应用程序中使用了第三方库.该第三方库在每次应用程序启动时都会引发一个自定义的未捕获异常.该异常是无害的,仅用于内部记录到第三方库.由于未捕获到此异常,因此,每当我启动应用程序以通知我该问题时,它将导致我的Eclipse IDE切换到调试透视图并挂起线程执行.我必须手动告诉Eclipse忽略它,而每次都重新开始调试.这很烦人.我不能更改第三方库来解决此问题.

I am using a third party library in my Java application. This third party library throws a custom uncaught exception at every application startup. The exception is harmless and only used for logging purposes internally to the third party library. Since this exception is not caught it causes my Eclipse IDE to switch into the debug perspective and suspend the thread execution everytime I start the application to inform me of the issue. I have to manually tell Eclipse to ignore this and just resume debugging every time. This is very annoying. I cannot change the third party library in order to fix this issue.

是否有一种方法可以告诉Eclipse IDE忽略特定类型的未捕获异常?

Is there a way to tell the Eclipse IDE to ignore a specific type of uncaught exception?

我尝试了步骤过滤",但是(我认为)由于自定义未捕获的异常不在堆栈跟踪中,因此它没有从调试器中过滤掉.这是我第一次涉足步进过滤,所以我可能使用错了.这是一个示例堆栈跟踪.

I tried "Step Filtering" but (I think) since the custom uncaught exception is not in the stack trace it is not being filtered out from the debugger. This is my first foray into Step Filtering so I could be using it wrong. Here is a sample stack trace.

Daemon Thread [Thread-13] (Suspended (exception CustomThirdPartyException)) 
    ThreadPoolExecutor$Worker.run() line: not available [local variables unavailable]   
    Thread.run() line: not available

jluzwick在禁用Eclipse中所有未捕获的异常之后使用我们自己的记录器监视未捕获的异常的方法在技术上可以正常工作,但这并不理想,如果记录器损坏,我们可能会错过一些事情.

jluzwick's work around of using our own logger to watch for uncaught exceptions after disabling all uncaught exceptions in Eclipse could technically work but it is not ideal and it's possible we could miss things if our logger is broken.

mazaneicha的解决方案似乎处在正确的轨道上,但我无法使其完全按照我想要的方式工作.这可能是由于我的用户错误.

mazaneicha's Solution seemed to be on the right track but I could not get it to work exactly the way I wanted. This may be due to user error on my part.

jluzwick和mazaneicha都可以解决此问题,但Konstantin Komissarchik的回答正确",应将其推回给图书馆的创建者进行修复.有时,一种技术解决方案不是正确的解决方案.

jluzwick and mazaneicha both had possible work arounds to this issue but Konstantin Komissarchik had the "correct" answer in that this should be pushed back to the library's creators to fix. Sometimes a technical solution is not the right one.

推荐答案

一个旧线程,但认为我要添加一点.

An old thread, but figured I'd add a bit to it.

至少在Eclipse Indigo中:在Debug Perspective-> Breakpoints视图中:

In at least Eclipse Indigo: In the Debug Perspective->Breakpoints view:

  1. 为要暂停的异常(和可能的子类)指定一个断点.这是通过单击添加Java异常断点"来完成的.一个图标,它是J和一个感叹号.
  2. 右键单击断点,然后选择断点属性"
  3. 转到过滤"
  4. 指定要忽略的类或包.这会将它们添加到列表中.只需确保取消选中它们即可确定它是排他性的(不要停在指定位置)

我倾向于使用它,以便我可以将NullPointerExceptions指定为一般的异常断点,但是忽略来自第三方库的软件包.

I tend to use this so that I can specify NullPointerExceptions as a general exception breakpoint, but ignore packages that are from third party libraries.

这篇关于如何忽略Eclipse中未捕获的异常的特定类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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