Findbugs 贡献:方法从没有历史记录的 catch 块中抛出替代异常
Findbugs contrib: Method throws alternative exception from catch block without history
fb-contrib 抱怨
Method throws alternative exception from catch block without history
在我的 try/catch 街区之一。
如何解决这个问题?是否有关于如何解决此问题的详细说明?
捕获到原始异常,您的代码抛出另一个异常,但未在 java.lang.Throwable cause
中包含原始异常
找到了一些东西here:
This method catches an exception, and throws a different exception, without incorporating the
original exception. Doing so hides the original source of the exception making debugging and fixing
these problems difficult. It is better to use the constructor of this new exception that takes an
original exception so that this detail can be passed along to the user.
FindBugs 贡献的精彩内容!
所以传递原因,记录它,......对你捕获的东西做点什么。
希望这对某人有所帮助。
示例:
try {
...
} catch (final SomeException theOriginalCause) {
// throw new SomeOtherException(); // Bad !
throw new SomeOtherException(theOriginalCause); // Good.
}
fb-contrib 抱怨
Method throws alternative exception from catch block without history
在我的 try/catch 街区之一。
如何解决这个问题?是否有关于如何解决此问题的详细说明?
捕获到原始异常,您的代码抛出另一个异常,但未在 java.lang.Throwable cause
找到了一些东西here:
This method catches an exception, and throws a different exception, without incorporating the original exception. Doing so hides the original source of the exception making debugging and fixing these problems difficult. It is better to use the constructor of this new exception that takes an original exception so that this detail can be passed along to the user.
FindBugs 贡献的精彩内容! 所以传递原因,记录它,......对你捕获的东西做点什么。 希望这对某人有所帮助。
示例:
try {
...
} catch (final SomeException theOriginalCause) {
// throw new SomeOtherException(); // Bad !
throw new SomeOtherException(theOriginalCause); // Good.
}