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)
| 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 |
no test coverage detected