/** * */ protected Object evaluateOld(int id) throws Throwable { try { return interpreter.eval("bshEvaluator.evaluateOld(" + id + ")"); } catch(TargetError te) { throw te.getTarget(); } catch(EvalError ee) { throw ee; } }
/** Override toEvalError to throw TargetError type. */ public EvalError toEvalError( String msg, SimpleNode node, CallStack callstack ) { if ( msg == null ) msg = getMessage(); else msg = msg + ": " + getMessage(); return new TargetError( msg, t, node, callstack, false ); } }
public JDemoApplet(String type) { super("Demo"); // String type = getParameter("type"); if ( type != null && type.equals("desktop") ) // start the desktop try { interpreter = new Interpreter(); interpreter.eval( "desktop()" ); } catch ( TargetError te ) { te.printStackTrace(); System.out.println( te.getTarget() ); te.getTarget().printStackTrace(); } catch ( EvalError evalError ) { System.out.println( evalError ); evalError.printStackTrace(); } else { getContentPane().setLayout(new BorderLayout()); setSize(600,200); JConsole console = new JConsole(); getContentPane().add("Center", console); interpreter = new Interpreter( console ); new Thread(interpreter).start(); setVisible(true); } } public static void main(String[] args) {
ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); se.initCause(e.getTarget()); throw se; } catch (EvalError e) {
error("Target Exception: " + e.getMessage() ); if ( e.inNativeCode() ) e.printStackTrace( DEBUG.get(), getErr() ); if(!interactive) EOF = true; setu("$_e", e.getTarget());
if ( e.inNativeCode() ) e.printStackTrace( DEBUG, err ); if(!interactive) eof = true; setu("$_e", e.getTarget());
thrown = e.getTarget(); thrown = ((TargetError) thrown.getCause()).getTarget(); throw new TargetError(thrown, this, callstack);
if ( te instanceof EvalError ) if ( te instanceof TargetError ) isNative = ((TargetError)te).inNativeCode(); else isNative = false; throw new TargetError( msg, te, this, callstack, isNative );
ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); se.initCause(e.getTarget()); throw se; } catch (EvalError e) {
if ( te instanceof EvalError ) if ( te instanceof TargetError ) isNative = ((TargetError)te).inNativeCode(); else isNative = false; throw new TargetError( msg, te, node, callstack, isNative );
/** * */ protected Object evaluateEstimated(int id) throws Throwable { try { return interpreter.eval("bshEvaluator.evaluateEstimated(" + id + ")"); } catch(TargetError te) { throw te.getTarget(); } catch(EvalError ee) { throw ee; } }
private Object evalSource(Object source, ScriptContext scriptContext) throws ScriptException { bsh.NameSpace contextNameSpace = getEngineNameSpace(scriptContext); Interpreter bsh = getInterpreter(); bsh.setNameSpace(contextNameSpace); bsh.setOut(toPrintStream(scriptContext.getWriter())); bsh.setErr(toPrintStream(scriptContext.getErrorWriter())); try { if (source instanceof Reader) { return bsh.eval((Reader) source); } else { return bsh.eval((String) source); } //} catch (ParseException e) { // explicit parsing error TODO how to handle parse exception ? //throw new ScriptException(e.toString()); //e.getErrorSourceFile(), e.getErrorLineNumber()); } catch (TargetError e) { // The script threw an application level exception // set it as the cause ? ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); se.initCause(e.getTarget()); throw se; } catch (EvalError e) { // The script couldn't be evaluated properly throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); } catch (InterpreterError e) { // The interpreter had a fatal problem throw new ScriptException(e.toString()); } }
if ( te instanceof EvalError ) if ( te instanceof TargetError ) isNative = ((TargetError)te).inNativeCode(); else isNative = false; throw new TargetError( msg, te, node, callstack, isNative ); } catch ( UtilEvalError e ) { throw e.toEvalError( node, callstack );
type, dimensionsNode.definedDimensions); } catch( NegativeArraySizeException e1 ) { throw new TargetError( e1, node, callstack ); } catch( Exception e ) { throw new EvalError("Can't construct primitive array: " +
/** * */ protected Object evaluate(int id) throws Throwable { try { return interpreter.eval("bshEvaluator.evaluate(" + id + ")"); } catch(TargetError te) { throw te.getTarget(); } catch(EvalError ee) { throw ee; } }
private Object evalSource(Object source, ScriptContext scriptContext) throws ScriptException { try ( Interpreter bsh = getInterpreter() ) { NameSpace contextNameSpace = getEngineNameSpace(scriptContext); bsh.setNameSpace(contextNameSpace); bsh.setOut(toPrintStream(scriptContext.getWriter())); bsh.setErr(toPrintStream(scriptContext.getErrorWriter())); if (source instanceof Reader) { return bsh.eval((Reader) source); } else { return bsh.eval((String) source); } } catch (ParseException e) { // explicit parsing error throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); } catch (TargetError e) { // The script threw an application level exception ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); se.initCause(e.getTarget()); throw se; } catch (EvalError e) { // The script couldn't be evaluated properly throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); } catch (IOException e) { throw new ScriptException(e.toString()); } }
if ( te instanceof EvalError ) if ( te instanceof TargetError ) isNative = ((TargetError)te).inNativeCode(); else isNative = false; throw new TargetError( msg, te, this, callstack, isNative ); } catch ( UtilEvalError e ) { throw e.toEvalError( this, callstack );