From 915b7d4d3629cd63a561b8764f929c93aef0ae81 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 10 May 2007 16:59:00 +0000 Subject: [PATCH] forwarding cause of exception --- tools/cooja/java/se/sics/cooja/CoreComm.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/CoreComm.java b/tools/cooja/java/se/sics/cooja/CoreComm.java index fb20a7d40..54a7aa3f0 100644 --- a/tools/cooja/java/se/sics/cooja/CoreComm.java +++ b/tools/cooja/java/se/sics/cooja/CoreComm.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: CoreComm.java,v 1.7 2007/05/09 07:18:36 fros4943 Exp $ + * $Id: CoreComm.java,v 1.8 2007/05/10 16:59:00 fros4943 Exp $ */ package se.sics.cooja; @@ -255,14 +255,14 @@ public abstract class CoreComm { public static CoreComm createCoreComm(String className, File libFile) throws MoteTypeCreationException { if (!generateLibSourceFile(className)) - throw new MoteTypeCreationException("Could not generate library source file: " + className); + throw new MoteTypeCreationException("Could not generate corecomm source file: " + className + ".java"); if (!compileSourceFile(className)) - throw new MoteTypeCreationException("Could not compile library: " + className); + throw new MoteTypeCreationException("Could not compile corecomm source file: " + className + ".java"); Class newCoreCommClass = loadClassFile(className); if (newCoreCommClass == null) - throw new MoteTypeCreationException("Could not load library class file: " + className); + throw new MoteTypeCreationException("Could not load corecomm class file: " + className + ".class"); try { Constructor constr = newCoreCommClass.getConstructor(new Class[] { File.class }); @@ -273,14 +273,9 @@ public abstract class CoreComm { fileCounter++; return newCoreComm; - } catch (NoSuchMethodException e) { - throw new MoteTypeCreationException("Error when creating library instance (#1): " + className); - } catch (InstantiationException e) { - throw new MoteTypeCreationException("Error when creating library instance (#2): " + className); - } catch (InvocationTargetException e) { - throw new MoteTypeCreationException("Error when creating library instance (#3): " + className); - } catch (IllegalAccessException e) { - throw new MoteTypeCreationException("Error when creating library instance (#4): " + className); + } catch (Exception e) { + throw (MoteTypeCreationException) new MoteTypeCreationException( + "Error when creating library instance: " + className).initCause(e); } }