pmd: fix #1087 PreserveStackTrace (still) ignores initCause()
one more test, extended documentation example
This commit is contained in:
parent
b77de63950
commit
2d655f4684
@ -1354,7 +1354,12 @@ public class Foo {
|
||||
try{
|
||||
Integer.parseInt("a");
|
||||
} catch (Exception e) {
|
||||
throw new Exception(e);
|
||||
throw new Exception(e); // first possibility to create exception chain
|
||||
}
|
||||
try {
|
||||
Integer.parseInt("a");
|
||||
} catch (Exception e) {
|
||||
throw (IllegalStateException)new IllegalStateException().initCause(e); // second possibility to create exception chain.
|
||||
}
|
||||
}
|
||||
void bad() {
|
||||
|
@ -462,6 +462,12 @@ public class Test {
|
||||
noSuchElementException.initCause(arrayIndexOutOfBoundsException);
|
||||
throw noSuchElementException;
|
||||
}
|
||||
|
||||
try {
|
||||
// do something
|
||||
} catch (ArrayOutOfBoundsException e) {
|
||||
throw (IllegalStateException)new IllegalStateException().initCause(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user