Skip to content

Commit 1215dd8

Browse files
committed
ScriptREPL: recover gracefully from failed copy
When copying variables between languages, if something goes wrong, let's just catch it, dump the error, and try to continue. Otherwise, the language switch operation will completely fail.
1 parent 1aea31a commit 1215dd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/org/scijava/script/ScriptREPL.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,12 @@ public void lang(final String langName) {
252252
new DefaultScriptInterpreter(language);
253253

254254
// preserve state of the previous interpreter
255-
copyBindings(interpreter, newInterpreter);
255+
try {
256+
copyBindings(interpreter, newInterpreter);
257+
}
258+
catch (final Throwable t) {
259+
t.printStackTrace(out);
260+
}
256261
out.println("language -> " +
257262
newInterpreter.getLanguage().getLanguageName());
258263
interpreter = newInterpreter;

0 commit comments

Comments
 (0)