开发者

java - automatically printing stack traces for uncaught exceptions

Is ther开发者_高级运维e a way to have java print a stack trace to console for all uncaught exceptions like in many IDEs, other than overwriting the uncaught exception handler in the thread/threadgroup?


I'm not sure I understand your question. What you describe is already the default behavior of most if not all JVMs: a thread that gets hit by an uncaught exception will print the stack trace and exit. If you want it to do something different, then the uncaught exception handler is the way to do it.


You mean something like:

catch(MyException e){
    e.printStackTrace();
    throw e;
}

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜