pmd: fix #1087 PreserveStackTrace (still) ignores initCause()

one more test, extended documentation example
This commit is contained in:
Andreas Dangel 2013-04-25 18:35:06 +02:00
parent b77de63950
commit 2d655f4684
2 changed files with 14 additions and 3 deletions

View File

@ -1353,14 +1353,19 @@ public class Foo {
void good() {
try{
Integer.parseInt("a");
} catch(Exception e){
throw new Exception(e);
} catch (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() {
try{
Integer.parseInt("a");
} catch(Exception e){
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}

View File

@ -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>