How to find cause of exception if type is Throwable
Give this method here:
public SomeClass(Throwable stackTrace) {
super();
this.stackTrace = stackTr开发者_运维知识库ace;
}
How can I find out what class type stacktrace
originally was before being passed in?
stacktrace.getClass().getName()
or
stacktrace instanceof CLASS_YOU_WANT_TO_TRY
You make this determination by handling exceptions as explicitly as possible. That includes not ever, EVER, catching Throwable
and handling exceptions as near to the code that threw it as possible. I'm not sure what you're trying to do by constructing a POJO with a Throwable
but it's probably not a path that will lead you to much enlightenment.
精彩评论