Package net.sourceforge.htmlunit.corejs.javascript

Examples of net.sourceforge.htmlunit.corejs.javascript.JavaScriptException


      }
      result = jsEngine.callFunction(htmlPage, jsFunction, window,
          jsThis, jsArgs);    
    } catch (ScriptException se) {
      if (se.getCause() instanceof JavaScriptException) {
        JavaScriptException ex = (JavaScriptException) se.getCause();
        if (logger.isLoggable(TreeLogger.INFO)) {
          logger.log(TreeLogger.INFO, "INVOKE: JavaScriptException " + ex
              + ", message: " + ex.getMessage() + " when invoking "
              + methodName);
        }
        return new ExceptionOrReturnValue(true, makeValueFromJsval(jsContext,
            ex.getValue()));
      } else {
        if (logger.isLoggable(TreeLogger.INFO)) {
          logger.log(TreeLogger.INFO, "INVOKE: exception " + se + ", message: "
            + se.getMessage() + " when invoking " + methodName);
        }
        return new ExceptionOrReturnValue(true, makeValueFromJsval(jsContext,
          Undefined.instance));
      }
    } catch (Exception ex) {
      if (logger.isLoggable(TreeLogger.INFO)) {
        logger.log(TreeLogger.INFO, "INVOKE: exception " + ex + ", message: "
            + ex.getMessage() + " when invoking " + methodName);
      }
      return new ExceptionOrReturnValue(true, makeValueFromJsval(jsContext,
          Undefined.instance));
    }
    if (logger.isLoggable(TreeLogger.INFO)) {
View Full Code Here


    try {
      final Reader reader = new FileReader(file);

      return run(context, scope, reader, file.getName());
    } catch (IOException ex) {
      throw new JavaScriptException("Error opening input file.",
          file.getAbsolutePath(), 0);
    }
  }
View Full Code Here

    try {
      /* Executes the script in the current context. */
      return context.evaluateReader(scope, reader, name, 1, null);
    } catch (EcmaError ex) {

      final JavaScriptException wrappedEx = new JavaScriptException(
          "Error executing script: " + name, name, 0);

      wrappedEx.initCause(ex);

      throw wrappedEx;
    } catch (IOException ex) {
      throw new JavaScriptException("Error reading script: " + name, name, 0);
    }
  }
View Full Code Here

          files.add(((File)result).getAbsolutePath());
        } else if (InputStream.class.isInstance(result)) {
          input.add((InputStream)result);
        }
      } else {
        throw new JavaScriptException(arguments[i].toString() +
            " not found in the context path.", "", 0);
      }
    }

    if (files.size() > 0) {
View Full Code Here

          } else if (InputStream.class.isInstance(result)) {
            input.add((InputStream)result);
          }
        } catch(IOException ex) {}
      } else {
        throw new JavaScriptException(arguments[i].toString() +
            " not found in the context path.", "", 0);
      }
    }

    if (input.size() > 0) {
View Full Code Here

      }
      result = jsEngine.callFunction(htmlPage, jsFunction, window,
          jsThis, jsArgs);
    } catch (ScriptException se) {
      if (se.getCause() instanceof JavaScriptException) {
        JavaScriptException ex = (JavaScriptException) se.getCause();
        if (logger.isLoggable(TreeLogger.INFO)) {
          logger.log(TreeLogger.INFO, "INVOKE: JavaScriptException " + ex
              + ", message: " + ex.getMessage() + " when invoking "
              + methodName);
        }
        return new ExceptionOrReturnValue(true, makeValueFromJsval(jsContext,
            ex.getValue()));
      } else {
        if (logger.isLoggable(TreeLogger.INFO)) {
          logger.log(TreeLogger.INFO, "INVOKE: exception " + se + ", message: "
            + se.getMessage() + " when invoking " + methodName);
        }
        return new ExceptionOrReturnValue(true, makeValueFromJsval(jsContext,
          Undefined.instance));
      }
    } catch (Exception ex) {
      if (logger.isLoggable(TreeLogger.INFO)) {
        logger.log(TreeLogger.INFO, "INVOKE: exception " + ex + ", message: "
            + ex.getMessage() + " when invoking " + methodName);
      }
      return new ExceptionOrReturnValue(true, makeValueFromJsval(jsContext,
          Undefined.instance));
    }
    if (logger.isLoggable(TreeLogger.INFO)) {
View Full Code Here

     */
    @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());
            }
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.htmlunit.corejs.javascript.JavaScriptException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.