forwarding cause of exception

This commit is contained in:
fros4943 2007-05-10 16:59:00 +00:00
parent 82aa4b4926
commit 915b7d4d36

View File

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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; package se.sics.cooja;
@ -255,14 +255,14 @@ public abstract class CoreComm {
public static CoreComm createCoreComm(String className, File libFile) public static CoreComm createCoreComm(String className, File libFile)
throws MoteTypeCreationException { throws MoteTypeCreationException {
if (!generateLibSourceFile(className)) 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)) 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); Class newCoreCommClass = loadClassFile(className);
if (newCoreCommClass == null) 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 { try {
Constructor constr = newCoreCommClass.getConstructor(new Class[] { File.class }); Constructor constr = newCoreCommClass.getConstructor(new Class[] { File.class });
@ -273,14 +273,9 @@ public abstract class CoreComm {
fileCounter++; fileCounter++;
return newCoreComm; return newCoreComm;
} catch (NoSuchMethodException e) { } catch (Exception e) {
throw new MoteTypeCreationException("Error when creating library instance (#1): " + className); throw (MoteTypeCreationException) new MoteTypeCreationException(
} catch (InstantiationException e) { "Error when creating library instance: " + className).initCause(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);
} }
} }