/** * {@inheritDoc} */ @Override public void onExceptionThrown(final Context cx, final Throwable t) { if (LOG.isTraceEnabled()) { if (t instanceof JavaScriptException) { final JavaScriptException e = (JavaScriptException) t; LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.getValue())); } else { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + t.getCause()); } } }
public Object next() { if (!iterator.hasNext()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return iterator.next(); }
/** * Create a JavaScript exception wrapping the given JavaScript value * * @param value the JavaScript value thrown. */ public JavaScriptException(Object value, String sourceName, int lineNumber) { recordErrorOrigin(sourceName, lineNumber, null, 0); this.value = value; // if JavaScriptException is caused by a NativeError, link that as a nested exception if (value instanceof NativeError) { Object src = ScriptableObject.getProperty((NativeError) value, "at"); if (src instanceof Throwable) initCause((Throwable) src); } }
/** * {@inheritDoc} */ @Override public void onExceptionThrown(final Context cx, final Throwable t) { if (LOG.isTraceEnabled()) { if (t instanceof JavaScriptException) { final JavaScriptException e = (JavaScriptException) t; if (LOG.isTraceEnabled()) { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.details())); } } else if (t instanceof EcmaError) { final EcmaError e = (EcmaError) t; if (LOG.isTraceEnabled()) { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.details())); } } else { if (LOG.isTraceEnabled()) { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + t.getCause()); } } } }
/** * @deprecated Use {@link RhinoException#lineNumber()} from the super class. */ public int getLineNumber() { return lineNumber(); }
/** * {@inheritDoc} */ @Override public void onExceptionThrown(final Context cx, final Throwable t) { if (LOG.isTraceEnabled()) { if (t instanceof JavaScriptException) { final JavaScriptException e = (JavaScriptException) t; LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.details())); } else if (t instanceof EcmaError) { final EcmaError e = (EcmaError) t; LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.details())); } else { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + t.getCause()); } } }
/** * {@inheritDoc} */ @Override public void onExceptionThrown(final Context cx, final Throwable t) { if (LOG.isTraceEnabled()) { if (t instanceof JavaScriptException) { final JavaScriptException e = (JavaScriptException) t; LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.getValue())); } else { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + t.getCause()); } } }
public static void throwStopIteration(Object obj) { throw new JavaScriptException( NativeIterator.getStopIterationObject((Scriptable)obj), "", 0); }
/** * {@inheritDoc} */ @Override public void onExceptionThrown(final Context cx, final Throwable t) { if (LOG.isTraceEnabled()) { if (t instanceof JavaScriptException) { final JavaScriptException e = (JavaScriptException) t; LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + Context.toString(e.getValue())); } else { LOG.trace(getSourceName(cx) + ":" + getFirstLine(cx) + " Exception thrown: " + t.getCause()); } } }
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); }
final Object value = ((JavaScriptException) getCause()).getValue();
private static Object thawGenerator(CallFrame frame, int stackTop, GeneratorState generatorState, int op) { // we are resuming execution frame.frozen = false; int sourceLine = getIndex(frame.idata.itsICode, frame.pc); frame.pc += 2; // skip line number data if (generatorState.operation == NativeGenerator.GENERATOR_THROW) { // processing a call to <generator>.throw(exception): must // act as if exception was thrown from resumption point return new JavaScriptException(generatorState.value, frame.idata.itsSourceFile, sourceLine); } if (generatorState.operation == NativeGenerator.GENERATOR_CLOSE) { return generatorState.value; } if (generatorState.operation != NativeGenerator.GENERATOR_SEND) throw Kit.codeBug(); if (op == Token.YIELD) frame.stack[stackTop] = generatorState.value; return Scriptable.NOT_FOUND; }
final Object value = ((JavaScriptException) getCause()).getValue();
throw new JavaScriptException("Interpreter not present", filename, linep[0]);
final Object value = ((JavaScriptException) getCause()).getValue();
/** * Encapsulates the given {@link DOMException} into a Rhino-compatible exception. * * @param exception the exception to encapsulate * @return the created exception */ protected RhinoException asJavaScriptException(final DOMException exception) { final Window w = getWindow(); exception.setPrototype(w.getPrototype(exception.getClass())); exception.setParentScope(w); // get current line and file name // this method can only be used in interpreted mode. If one day we choose to use compiled mode, // then we'll have to find an other way here. final String fileName; final int lineNumber; if (Context.getCurrentContext().getOptimizationLevel() == -1) { final int[] linep = new int[1]; final String sourceName = new Interpreter().getSourcePositionFromStack(Context.getCurrentContext(), linep); fileName = sourceName.replaceFirst("script in (.*) from .*", "$1"); lineNumber = linep[0]; } else { throw new Error("HtmlUnit not ready to run in compiled mode"); } exception.setLocation(fileName, lineNumber); return new JavaScriptException(exception, fileName, lineNumber); }
final Object value = ((JavaScriptException) getCause()).getValue();
private RhinoException asJavaScriptException(final DOMException exception) { exception.setPrototype(getWindow().getPrototype(exception.getClass())); exception.setParentScope(getWindow()); // get current line and file name // this method can only be used in interpreted mode. If one day we choose to use compiled mode, // then we'll have to find an other way here. final String fileName; final int lineNumber; if (Context.getCurrentContext().getOptimizationLevel() == -1) { final int[] linep = new int[1]; final String sourceName = new Interpreter().getSourcePositionFromStack(Context.getCurrentContext(), linep); fileName = sourceName.replaceFirst("script in (.*) from .*", "$1"); lineNumber = linep[0]; } else { throw new Error("HtmlUnit not ready to run in compiled mode"); } exception.setLocation(fileName, lineNumber); return new JavaScriptException(exception, fileName, lineNumber); }
final Object value = ((JavaScriptException) getCause()).getValue();
/** * Encapsulates the given {@link DOMException} into a Rhino-compatible exception. * * @param exception the exception to encapsulate * @return the created exception */ protected RhinoException asJavaScriptException(final DOMException exception) { final Window w = getWindow(); exception.setPrototype(w.getPrototype(exception.getClass())); exception.setParentScope(w); // get current line and file name // this method can only be used in interpreted mode. If one day we choose to use compiled mode, // then we'll have to find an other way here. final String fileName; final int lineNumber; if (Context.getCurrentContext().getOptimizationLevel() == -1) { final int[] linep = new int[1]; final String sourceName = new Interpreter().getSourcePositionFromStack(Context.getCurrentContext(), linep); fileName = sourceName.replaceFirst("script in (.*) from .*", "$1"); lineNumber = linep[0]; } else { throw new Error("HtmlUnit not ready to run in compiled mode"); } exception.setLocation(fileName, lineNumber); return new JavaScriptException(exception, fileName, lineNumber); }