java: when rethrowing exceptions, store the original

Change-Id: I8a2a264597d0b1ae06b08136fea36003682380b5
This commit is contained in:
Noel Grandin
2014-10-16 14:44:23 +02:00
parent 03c7c26cbe
commit 93056481e8
5 changed files with 42 additions and 41 deletions

View File

@@ -57,14 +57,16 @@ public class StrictResolver implements Resolver {
try {
m = resolveArguments(sd, c);
} catch (ClassNotFoundException e) {
throw new NoSuchMethodException(
"StrictResolver.getProxy: Can't find method: " + sd.getMethodName()
+ ":" + e.getMessage());
} catch (NoSuchMethodException e) {
throw new NoSuchMethodException(
"StrictResolver.getProxy: Can't find method: " + sd.getMethodName()
+ ":" + e.getMessage());
} catch (ClassNotFoundException ex1) {
NoSuchMethodException ex2 = new NoSuchMethodException(
"StrictResolver.getProxy: Can't find method: " + sd.getMethodName());
ex2.initCause(ex1);
throw ex2;
} catch (NoSuchMethodException ex1) {
NoSuchMethodException ex2 = new NoSuchMethodException(
"StrictResolver.getProxy: Can't find method: " + sd.getMethodName());
ex2.initCause(ex1);
throw ex2;
}
ScriptProxy sp = new ScriptProxy(m);
@@ -76,12 +78,16 @@ public class StrictResolver implements Resolver {
try {
o = c.newInstance();
} catch (InstantiationException ie) {
throw new NoSuchMethodException(
"getScriptProxy: Can't instantiate: " + c.getName());
} catch (IllegalAccessException iae) {
throw new NoSuchMethodException(
"getScriptProxy: Can't access: " + c.getName());
} catch (InstantiationException ex1) {
NoSuchMethodException ex2 = new NoSuchMethodException(
"getScriptProxy: Can't instantiate: " + c.getName());
ex2.initCause(ex1);
throw ex2;
} catch (IllegalAccessException ex1) {
NoSuchMethodException ex2 = new NoSuchMethodException(
"getScriptProxy: Can't access: " + c.getName());
ex2.initCause(ex1);
throw ex2;
}
sp.setTargetObject(o);