1111
1212import javax .script .ScriptEngine ;
1313import javax .script .ScriptEngineManager ;
14- import javax .script .ScriptException ;
1514
1615import org .renjin .eval .EvalException ;
1716import org .renjin .parser .RParser ;
@@ -259,6 +258,7 @@ public void start() {
259258 public void uncaughtException (final Thread t , final Throwable e ) {
260259 terminalException = toSketchException (e );
261260 try {
261+ log ("There is an unexpected exception." );
262262 handleMethods ("dispose" );
263263 } catch (final Exception noop ) {
264264 // give up
@@ -295,8 +295,11 @@ public void setup() {
295295 wrapProcessingVariables ();
296296 if (this .mode == Mode .STATIC ) {
297297 try {
298+ log ("The mode is static, run the program directly." );
298299 this .renjinEngine .eval (this .programText );
299- } catch (ScriptException exception ) {
300+ log ("Evaluate the code in static mode." );
301+ } catch (final Exception exception ) {
302+ log ("There is exception when evaluate the code in static mode." );
300303 terminalException = toSketchException (exception );
301304 exitActual ();
302305 }
@@ -308,6 +311,7 @@ public void setup() {
308311 } else {
309312 System .out .println ("The program is in mix mode now." );
310313 }
314+ log ("Setup done" );
311315 }
312316
313317 /**
@@ -388,6 +392,10 @@ private static RSketchError toSketchException(Throwable t) {
388392 final RSketchError e = (RSketchError ) t ;
389393 return e ;
390394 }
395+ if (t instanceof ClassCastException ) {
396+ final RSketchError e = (RSketchError ) t ;
397+ return e ;
398+ }
391399 log ("No exception type detected." );
392400 return null ;
393401 }
0 commit comments