more informative error messages at simulation error

This commit is contained in:
Fredrik Osterlind 2012-02-16 15:51:32 +01:00
parent 43062b6d74
commit 2c9316c5fa
2 changed files with 11 additions and 3 deletions

View file

@ -345,6 +345,10 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
lastExecute = t;
} catch (EmulationException e) {
String stackTraceOutput = sendCLICommandAndPrint("stacktrace");
if (stackTraceOutput == null) {
stackTraceOutput = "";
}
stackTraceOutput = e.getMessage() + "\n\n" + stackTraceOutput;
throw (ContikiError)
new ContikiError(stackTraceOutput).initCause(e);
}

View file

@ -253,8 +253,8 @@ public class Simulation extends Observable implements Runnable {
this.setChanged();
this.notifyObservers(this);
TimeEvent nextEvent = null;
try {
TimeEvent nextEvent;
while (isRunning) {
/* Handle all poll requests */
@ -289,7 +289,11 @@ public class Simulation extends Observable implements Runnable {
/* Quit simulator if in test mode */
System.exit(1);
} else {
GUI.showErrorDialog(GUI.getTopParentContainer(), "Simulation error", e, false);
String title = "Simulation error";
if (nextEvent instanceof MoteTimeEvent) {
title += ": " + ((MoteTimeEvent)nextEvent).getMote();
}
GUI.showErrorDialog(GUI.getTopParentContainer(), title, e, false);
}
}
}