Package org.mozilla.javascript

Examples of org.mozilla.javascript.RhinoException


  protected void reportException(Exception e) {
    // Try to do a good job of reporting javascript exceptions.
    // We get better messages if we look for the Rhino-specific exceptions
    for (Throwable t = e; t != null; t = t.getCause())
      if (t instanceof RhinoException) {
        RhinoException re = (RhinoException) t;
        out.println("Javascript error: " + re.getMessage());
        return;
      }
    super.reportException(e);
  }
View Full Code Here


       
        if (jsError instanceof ScriptableObject) {
            ScriptableObject jsErrorScriptable = (ScriptableObject) jsError;
            Object wrappedRhinoException = ScriptableObject.getProperty(jsErrorScriptable, "rhinoException");
            if (wrappedRhinoException != null) {
                RhinoException rhinoException = (RhinoException)((NativeJavaObject)wrappedRhinoException).unwrap();
                return rhinoException.getScriptStackTrace();
//                StringWriter stringWriter = new StringWriter();
//                PrintWriter printWriter = new PrintWriter(stringWriter);
//                rhinoException.printStackTrace(printWriter);
//                return stringWriter.toString();
            }
View Full Code Here

      return module;
    } catch (Exception e) {
      String stackTrace = null;
      String failedModuleId = uri != null ? uri.toString() : id;
      if (e instanceof RhinoException) {
        RhinoException re = (RhinoException) e;
        stackTrace = re.getScriptStackTrace();
      }
     
      throw new RuntimeException("require() failed for module \"" + failedModuleId + "\". Exception: " + e + (stackTrace != null ? "\nJavaScript Stack trace: " + stackTrace + "\n[End: JavaScript Stack Trace]" : ""), e);
     
    }
View Full Code Here

            Context.enter();
            System.err.println(Context.toString(value));
            Context.exit();
        }
        if (ee instanceof RhinoException) {
            RhinoException re = (RhinoException)ee;
            System.err.println(re.details());
            System.err.println(re.getScriptStackTrace());
        } else {
            System.err.println(ee.getMessage());
            ee.printStackTrace(System.err);
        }
    }
View Full Code Here

        String template = new String(buffer, 0, read);
        String title = t instanceof RhinoException ?
                ((RhinoException)t).details() : t.getMessage();
        StringBuilder body = new StringBuilder();
        if (t instanceof RhinoException) {
            RhinoException rx = (RhinoException) t;
            if (errors != null && !errors.isEmpty()) {
                for (ScriptError error : errors) {
                    body.append(error.toHtml());
                }
            } else {
                body.append("<p><b>").append(rx.sourceName())
                        .append("</b>, line <b>").append(rx.lineNumber())
                        .append("</b></p>");
            }
            body.append("<h3>Script Stack</h3><pre>")
                    .append(rx.getScriptStackTrace())
                    .append("</pre>");
        }
        template = template.replaceAll("<% title %>", title);
        template = template.replaceAll("<% body %>", body.toString());
        response.setStatus(500);
View Full Code Here

                Context.enter();
                System.err.println(Context.toString(value));
                System.err.println(((JavaScriptException)cause).getScriptStackTrace());
                Context.exit();
            } else if (cause instanceof RhinoException) {
                RhinoException re = (RhinoException)cause;
                System.err.println(re.details());
                System.err.println(re.getScriptStackTrace());
            } else {
                System.err.println(cause.getMessage());
            }
            cause.printStackTrace(System.err);
            exitCode = 104;
View Full Code Here

  public String getFullMessage() {
    Throwable cause = getCause();
    String separator = System.getProperty("file.separator");
    if (cause instanceof RhinoException) {
      RhinoException re = (RhinoException) cause;
      StringWriter buf = new StringWriter();
      PrintWriter writer = new PrintWriter(buf);
      if (re instanceof WrappedException) {
        // Make sure we're not printing the "Wrapped ...Exception:" part
        writer.println(((WrappedException) re).getWrappedException()
            .getMessage());
      } else {
        writer.println(re.details());
      }
      String[] stackTrace = re.getScriptStackTrace().split("\\r\\n|\\n|\\r");
      String sourceName = re.sourceName();
      if (sourceName != null) {
        int lineNumber = re.lineNumber();
        // Report sourceName / lineNumber if it is not in the stack
        // trace already.
        // TODO Why is this needed? Rhino bug?
        if (stackTrace.length == 0 || stackTrace[0].indexOf(
            sourceName + ":" + lineNumber) == -1) {
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.RhinoException

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.