public static EcmaError typeError(String message) { return constructError("TypeError", message); }
/** * @deprecated Use * {@link ScriptRuntime#constructError(String,String,String,int,String,int)} * instead. */ public static EcmaError constructError(Context cx, String error, String message, Scriptable scope, String sourceName, int lineNumber, int columnNumber, String lineSource) { return ScriptRuntime.constructError(error, message, sourceName, lineNumber, lineSource, columnNumber); }
public static EcmaError constructError(String error, String message, int lineNumberDelta) { int[] linep = new int[1]; String filename = Context.getSourcePositionFromStack(linep); if (linep[0] != 0) { linep[0] += lineNumberDelta; } return constructError(error, message, filename, linep[0], null, 0); }
private static void reportError(String messageId, String arg) { String msg = ScriptRuntime.getMessage1(messageId, arg); throw ScriptRuntime.constructError("SyntaxError", msg); }
public static EcmaError constructError(String error, String message) { int[] linep = new int[1]; String filename = Context.getSourcePositionFromStack(linep); return constructError(error, message, filename, linep[0], null, 0); }
public static RuntimeException notFoundError(Scriptable object, String property) { // XXX: use object to improve the error message String msg = getMessage1("msg.is.not.defined", property); throw constructError("ReferenceError", msg); }
public void error(String message, String sourceURI, int line, String lineText, int lineOffset) { if (forEval) { // Assume error message strings that start with "TypeError: " // should become TypeError exceptions. A bit of a hack, but we // don't want to change the ErrorReporter interface. String error = "SyntaxError"; final String TYPE_ERROR_NAME = "TypeError"; final String DELIMETER = ": "; final String prefix = TYPE_ERROR_NAME + DELIMETER; if (message.startsWith(prefix)) { error = TYPE_ERROR_NAME; message = message.substring(prefix.length()); } throw ScriptRuntime.constructError(error, message, sourceURI, line, lineText, lineOffset); } if (chainedReporter != null) { chainedReporter.error( message, sourceURI, line, lineText, lineOffset); } else { throw runtimeError( message, sourceURI, line, lineText, lineOffset); } }
/** * Perform function call in reference context. Should always * return value that can be passed to * {@link #refGet(Ref, Context)} or {@link #refSet(Ref, Object, Context)} * arbitrary number of times. * The args array reference should not be stored in any object that is * can be GC-reachable after this method returns. If this is necessary, * store args.clone(), not args array itself. */ public static Ref callRef(Callable function, Scriptable thisObj, Object[] args, Context cx) { if (function instanceof RefCallable) { RefCallable rfunction = (RefCallable)function; Ref ref = rfunction.refCall(cx, thisObj, args); if (ref == null) { throw new IllegalStateException(rfunction.getClass().getName()+".refCall() returned null"); } return ref; } // No runtime support for now String msg = getMessage1("msg.no.ref.from.function", toString(function)); throw constructError("ReferenceError", msg); }
/** * Transforms the matrix. * @return the resulting matrix */ @JsxFunction public SVGMatrix inverse() { try { final SVGMatrix result = new SVGMatrix(getWindow()); result.svgMatrix_ = matrixTransformer_.inverse(svgMatrix_); return result; } catch (final IllegalArgumentException e) { throw ScriptRuntime.constructError("Error", e.getMessage()); } }
/** * Transforms the matrix. * @return the resulting matrix */ @JsxFunction public SVGMatrix inverse() { try { final SVGMatrix result = new SVGMatrix(getWindow()); result.svgMatrix_ = matrixTransformer_.inverse(svgMatrix_); return result; } catch (final IllegalArgumentException e) { throw ScriptRuntime.constructError("Error", e.getMessage()); } }
private static String num_to(double val, Object[] args, int zeroArgMode, int oneArgMode, int precisionMin, int precisionOffset) { int precision; if (args.length == 0) { precision = 0; oneArgMode = zeroArgMode; } else { /* We allow a larger range of precision than ECMA requires; this is permitted by ECMA. */ precision = ScriptRuntime.toInt32(args[0]); if (precision < precisionMin || precision > MAX_PRECISION) { String msg = ScriptRuntime.getMessage1( "msg.bad.precision", ScriptRuntime.toString(args[0])); throw ScriptRuntime.constructError("RangeError", msg); } } StringBuffer sb = new StringBuffer(); DToA.JS_dtostr(sb, oneArgMode, precision + precisionOffset, val); return sb.toString(); }
/** * Returns the value of the {@code frames} property. * @see <a href="http://msdn.microsoft.com/en-us/library/ms537459.aspx">MSDN documentation</a> * @return the live collection of frames contained by this document */ @JsxGetter(IE) public Object getFrames() { if (ScriptableObject.getTopLevelScope(this) == null) { throw ScriptRuntime.constructError("Error", "Not implemented"); } return getWindow().getFrames_js(); }
/** * Returns the value of the {@code frames} property. * @see <a href="http://msdn.microsoft.com/en-us/library/ms537459.aspx">MSDN documentation</a> * @return the live collection of frames contained by this document */ @JsxGetter(IE) public Object getFrames() { if (ScriptableObject.getTopLevelScope(this) == null) { throw ScriptRuntime.constructError("Error", "Not implemented"); } return getWindow().getFrames_js(); }
/** * Transforms the matrix. * @param x the x-coordinate of the vector * @param y the y-coordinate of the vector * @return the resulting matrix */ @JsxFunction public SVGMatrix rotateFromVector(final double x, final double y) { if (x == 0 || y == 0) { throw ScriptRuntime.constructError("Error", "Failed to execute 'rotateFromVector' on 'SVGMatrix': Arguments cannot be zero."); } final SVGMatrix result = new SVGMatrix(getWindow()); result.svgMatrix_ = matrixTransformer_.rotateFromVector(svgMatrix_, x, y); return result; }
/** * Transforms the matrix. * @param x the x-coordinate of the vector * @param y the y-coordinate of the vector * @return the resulting matrix */ @JsxFunction public SVGMatrix rotateFromVector(final double x, final double y) { if (x == 0 || y == 0) { throw ScriptRuntime.constructError("Error", "Failed to execute 'rotateFromVector' on 'SVGMatrix': Arguments cannot be zero."); } final SVGMatrix result = new SVGMatrix(getWindow()); result.svgMatrix_ = matrixTransformer_.rotateFromVector(svgMatrix_, x, y); return result; }
/** * Returns true if the element would be selected by the specified selector string; otherwise, returns false. * @param context the JavaScript context * @param thisObj the scriptable * @param args the arguments passed into the method * @param function the function * @return the value */ @JsxFunction({CHROME, FF, EDGE}) public static boolean matches( final Context context, final Scriptable thisObj, final Object[] args, final Function function) { final String selectorString = (String) args[0]; if (!(thisObj instanceof Element)) { throw ScriptRuntime.typeError("Illegal invocation"); } try { final DomNode domNode = ((Element) thisObj).getDomNodeOrNull(); return domNode != null && ((DomElement) domNode).matches(selectorString); } catch (final CSSException e) { throw ScriptRuntime.constructError("SyntaxError", "An invalid or illegal selector was specified (selector: '" + selectorString + "' error: " + e.getMessage() + ")."); } }
/** * Returns true if the element would be selected by the specified selector string; otherwise, returns false. * @param context the JavaScript context * @param thisObj the scriptable * @param args the arguments passed into the method * @param function the function * @return the value */ @JsxFunction({CHROME, FF, EDGE}) public static boolean matches( final Context context, final Scriptable thisObj, final Object[] args, final Function function) { final String selectorString = (String) args[0]; if (!(thisObj instanceof Element)) { throw ScriptRuntime.typeError("Illegal invocation"); } try { final DomNode domNode = ((Element) thisObj).getDomNodeOrNull(); return domNode != null && ((DomElement) domNode).matches(selectorString); } catch (final CSSException e) { throw ScriptRuntime.constructError("SyntaxError", "An invalid or illegal selector was specified (selector: '" + selectorString + "' error: " + e.getMessage() + ")."); } }
throw ScriptRuntime.constructError("ReferenceError", "Node cannot be inserted at the specified point in the hierarchy"); for (final DomNode child : fragment.getChildren()) { if (!isNodeInsertable((Node) child.getScriptableObject())) { throw ScriptRuntime.constructError("ReferenceError", "Node cannot be inserted at the specified point in the hierarchy"); throw ScriptRuntime.constructError("ReferenceError", e.getMessage());
throw ScriptRuntime.constructError("ReferenceError", "Node cannot be inserted at the specified point in the hierarchy"); for (final DomNode child : fragment.getChildren()) { if (!isNodeInsertable((Node) child.getScriptableObject())) { throw ScriptRuntime.constructError("ReferenceError", "Node cannot be inserted at the specified point in the hierarchy"); throw ScriptRuntime.constructError("ReferenceError", e.getMessage());