From 93056481e85548e1228d3b88e53ee59ed983576e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 16 Oct 2014 14:44:23 +0200 Subject: java: when rethrowing exceptions, store the original Change-Id: I8a2a264597d0b1ae06b08136fea36003682380b5 --- .../framework/provider/java/StrictResolver.java | 34 +++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'scripting') diff --git a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java index a7b580272c9f..08d06dce3b1d 100644 --- a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java +++ b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java @@ -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); -- cgit