Refine search
Context cx = factory.enterContext(); ScriptableObject scriptable = new ImporterTopLevel(cx); Scriptable scope = cx.initStandardObjects(scriptable); Context.javaToJS(entry.getValue(), scope)); return cx.evaluateString(scope, script, filename, 1, null); } catch (Error e) { throw new ScriptException(e.getMessage()); msg = String.valueOf(((JavaScriptException) e).getValue()); } else { msg = e.getMessage();
jscx.setOptimizationLevel( -1 ); jsscope = jscx.initStandardObjects( null, false ); Scriptable jsR = Context.toObject( sItem.getText(), jsscope ); jsscope.put( folder.getItem( i ).getText(), jsscope, jsR ); retval = false; } catch ( JavaScriptException e ) { String position = "(" + e.lineNumber() + ":" + e.columnNumber() + ")"; String message = BaseMessages.getString( PKG, "ScriptDialog.Exception.CouldNotExecuteScript", position ); testException = new KettleException( message, e );
trigger("var a=arguments[0];a.parentNode.removeChild(a);", anchor); } else { throw new JavaScriptException(element, "Unable to open tab", 1);
public Object eval(ScriptContext context) throws ScriptException { Object result = null; Context cx = RhinoScriptEngine.enterContext(); try { Scriptable scope = engine.getRuntimeScope(context); Object ret = script.exec(cx, scope); result = engine.unwrapReturnValue(ret); } catch (JavaScriptException jse) { if (DEBUG) jse.printStackTrace(); int line = (line = jse.lineNumber()) == 0 ? -1 : line; Object value = jse.getValue(); String str = (value != null && value.getClass().getName().equals("org.mozilla.javascript.NativeError") ? value.toString() : jse.toString()); throw new ExtendedScriptException(jse, str, jse.sourceName(), line); } catch (RhinoException re) { if (DEBUG) re.printStackTrace(); int line = (line = re.lineNumber()) == 0 ? -1 : line; throw new ExtendedScriptException(re, re.toString(), re.sourceName(), line); } finally { Context.exit(); } return result; }
public static String compile(String coffeeScript) throws ScriptException { Context ctx = Context.enter(); try { Scriptable scope = ctx.initStandardObjects(); Script script = (Script) new CoffeeScript(); script.exec(ctx, scope); NativeObject obj = (NativeObject) scope.get("CoffeeScript", scope); Function fun = (Function) obj.get("compile", scope); Object opts = ctx.evaluateString(scope, "({bare: true})", null, 1, null); String javaScript = (String) fun.call(ctx, scope, obj, new Object[] {coffeeScript, opts}); return javaScript; } catch (JavaScriptException e) { // Extract line and column of the error location in the CoffeeScript. // The below code is guessed from: // - Experimenting http://coffeescript.org/ with Chrome JavaScript Console // - https://code.google.com/p/wiquery/source/browse/trunk/src/main/java/org/mozilla/javascript/NativeError.java?spec=svn1010&r=1010 Scriptable syntaxError = (Scriptable) e.getValue(); Scriptable location = (Scriptable) ScriptableObject.getProperty(syntaxError, "location"); Double firstLine = (Double) ScriptableObject.getProperty(location, "first_line"); Double firstColumn = (Double) ScriptableObject.getProperty(location, "first_column"); throw new ScriptException("CoffeeScript syntax error", "", firstLine.intValue(), firstColumn.intValue()); } finally { Context.exit(); } } }
final Context rhinoContext = Context.enter(); rhinoContext.setLanguageVersion(((RhinoJavaScriptEngineFactory)getFactory()).rhinoLanguageVersion()); rhinoContext.setOptimizationLevel(optimizationLevel()); if (ScriptRuntime.hasTopCall(rhinoContext)) { scope = ScriptRuntime.getTopCallScope(rhinoContext); final ScriptException se = new ScriptException(t.details(), t.sourceName(), t.lineNumber()); ((Logger) bindings.get(SlingBindings.LOG)).error(t.getScriptStackTrace()); Object value = t.getValue(); if (value != null) { if (value instanceof Wrapper) { se.setStackTrace(t.getStackTrace());
@Override public Object eval(String script, ScriptContext context) throws ScriptException { Scriptable scope = setupScope(cx, context); String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null ? "<unknown>" : filename; try { return cx.evaluateString(scope, script, filename, 1, null); } catch (RhinoException e) { String msg; int line = (line = e.lineNumber()) == 0 ? -1 : line; if (e instanceof JavaScriptException) { msg = String.valueOf(((JavaScriptException) e).getValue()); } else { msg = e.getMessage(); } ScriptException scriptException = new ScriptException(msg, e.sourceName(), line); scriptException.initCause(e); throw scriptException; } finally { Context.exit(); } }
@Override public Object eval(Reader reader, ScriptContext context) throws ScriptException { Scriptable scope = setupScope(cx, context); String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null ? "<unknown>" : filename; try { return cx.evaluateReader(scope, reader, filename, 1, null); } catch (RhinoException e) { String msg; int line = (line = e.lineNumber()) == 0 ? -1 : line; if (e instanceof JavaScriptException) { msg = String.valueOf(((JavaScriptException) e).getValue()); } else { msg = e.getMessage(); } ScriptException scriptException = new ScriptException(msg, e.sourceName(), line); scriptException.initCause(e); throw scriptException; } catch (IOException e) { throw new ScriptException(e); } finally { Context.exit(); } }
final Context cx = Context.enter(); final Object result = doIt.call(cx, scope, null, new Object[] { input, compress }); } catch (final Exception e) { if (e instanceof JavaScriptException) { final Scriptable value = (Scriptable) ((JavaScriptException) e).getValue(); if (value != null && ScriptableObject.hasProperty(value, "message")) { final String message = ScriptableObject.getProperty(value, "message").toString(); Context.exit();
Context cx = Context.enter(); throw new JavaScriptException("function " + method + " not found."); theReturnValue = ScriptRuntime.call(cx, fun, global, args, null); if (theReturnValue instanceof Wrapper) { theReturnValue = ((Wrapper) theReturnValue).unwrap(); handleError(t); } finally { Context.exit();
Object x = args[0]; if (!(x instanceof CharSequence)) { if (cx.hasFeature(Context.FEATURE_STRICT_MODE) || cx.hasFeature(Context.FEATURE_STRICT_EVAL)) throw Context.reportRuntimeError0("msg.eval.nonstring.strict"); String message = ScriptRuntime.getMessage0("msg.eval.nonstring"); Context.reportWarning(message); return x; makeUrlForGeneratedScript(true, filename, lineNumber); Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", filename, lineNumber);
obj = ((JavaScriptException)t).getValue(); } else { cacheObj = true; if (obj == null) Kit.codeBug(); } else { obj = wrapException(t, scope, cx); exceptionName, obj, ScriptableObject.PERMANENT); if (isVisible(cx, t)) { "__exception__", Context.javaToJS(t, scope), ScriptableObject.PERMANENT|ScriptableObject.DONTENUM);
public Object eval(ScriptContext context) throws ScriptException { Object result = null; Context cx = RhinoScriptEngine.enterContext(); try { Scriptable scope = engine.getRuntimeScope(context); Object ret = script.exec(cx, scope); result = engine.unwrapReturnValue(ret); } catch (RhinoException re) { int line = (line = re.lineNumber()) == 0 ? -1 : line; String msg; if (re instanceof JavaScriptException) { msg = String.valueOf(((JavaScriptException)re).getValue()); } else { msg = re.toString(); } ScriptException se = new ScriptException(msg, re.sourceName(), line); se.initCause(re); throw se; } finally { Context.exit(); } return result; }
if (cx.getLanguageVersion() != Context.VERSION_1_2) { sourceBuf.append("anonymous"); sourceBuf.append(','); sourceBuf.append(ScriptRuntime.toString(args[i])); String funBody = ScriptRuntime.toString(args[arglen - 1]); sourceBuf.append(funBody); String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<eval'ed string>"; makeUrlForGeneratedScript(false, filename, linep[0]); reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", filename, linep[0]);
JCoffeeScriptCompileException (JavaScriptException e) { super(e.getValue().toString(), e); }
return Boolean.FALSE; Callable f = (Callable) v; Context cx = Context.getContext(); try { x.currentId = f.call(cx, x.iterator.getParentScope(), return Boolean.TRUE; } catch (JavaScriptException e) { if (e.getValue() instanceof NativeIterator.StopIteration) { return Boolean.FALSE; enumChangeObject(x); continue;
/** * Equivalent to executing "new $constructorName(message, sourceFileName, sourceLineNo)" from JavaScript. * @param cx the current context * @param scope the current scope * @param message the message * @return a JavaScriptException you should throw */ public static JavaScriptException throwCustomError(Context cx, Scriptable scope, String constructorName, String message) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); final Scriptable error = cx.newObject(scope, constructorName, new Object[] { message, filename, Integer.valueOf(linep[0]) }); return new JavaScriptException(error, filename, linep[0]); }
/** * Sets the value of the indexed property, creating it if need be. * * @param index the numeric index for the property * @param start the object whose property is being set * @param value value to set the property to */ public void put(int index, Scriptable start, Object value) { if (externalData != null) { if (index < externalData.getArrayLength()) { externalData.setArrayElement(index, value); } else { throw new JavaScriptException( ScriptRuntime.newNativeError(Context.getCurrentContext(), this, TopLevel.NativeErrors.RangeError, new Object[] { "External array index out of bounds " }), null, 0); } return; } if (putImpl(null, index, start, value)) return; if (start == this) throw Kit.codeBug(); start.put(index, start, value); }
private Object next(Context cx, Scriptable scope) { Boolean b = ScriptRuntime.enumNext(this.objectIterator); if (!b.booleanValue()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return ScriptRuntime.enumId(this.objectIterator, cx); }
/** * Equivalent to executing "new Error(message, sourceFileName, sourceLineNo)" from JavaScript. * @param cx the current context * @param scope the current scope * @param message the message * @return a JavaScriptException you should throw */ public static JavaScriptException throwError(Context cx, Scriptable scope, String message) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); final Scriptable error = newBuiltinObject(cx, scope, TopLevel.Builtins.Error, new Object[] { message, filename, Integer.valueOf(linep[0]) }); return new JavaScriptException(error, filename, linep[0]); }