MCPcopy Create free account
hub / github.com/akeranen/the-one / processAssertionError

Method processAssertionError

gui/DTNSimGUI.java:141–169  ·  view source on GitHub ↗

Processes assertion errors by showing a warning dialog to the user and pausing the simulation (if it's running) @param e The error that was thrown

(AssertionError e)

Source from the content-addressed store, hash-verified

139 * @param e The error that was thrown
140 */
141 private void processAssertionError(AssertionError e) {
142 String title = e.getClass().getSimpleName() + " (simulation paused)";
143 String msg = e.getMessage();
144 String txt = (msg != null ? msg : "") + " at simtime " +
145 SimClock.getIntTime() + "\n\ncaught at:\n" +
146 e.getStackTrace()[0].toString() +
147 "\nNote that the simulation might be in inconsistent state, "+
148 "continue only with caution.\n\n Show rest of the stack trace?";
149 // rest of the update cycle that caused the exception is skipped
150 // so the user is warned about the consequences
151
152
153 if (guiControls != null) {
154 guiControls.setPaused(true);
155 }
156
157 int selection = JOptionPane.showOptionDialog(getParentFrame(), txt,
158 title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
159 null, null, null);
160
161 if (selection == 0) {
162 txt = "";
163 for (StackTraceElement trace : e.getStackTrace()) {
164 txt += trace.toString()+"\n";
165 }
166 JOptionPane.showMessageDialog(getParentFrame(), txt,
167 "stack trace", JOptionPane.INFORMATION_MESSAGE);
168 }
169 }
170
171
172

Callers 2

runMethod · 0.95
runSimMethod · 0.95

Calls 6

getIntTimeMethod · 0.95
getParentFrameMethod · 0.95
getClassMethod · 0.80
toStringMethod · 0.65
getMessageMethod · 0.45
setPausedMethod · 0.45

Tested by

no test coverage detected