javax.script.ScriptException#initCause ( )源码实例Demo

下面列出了javax.script.ScriptException#initCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TencentKona-8   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码2 项目: jdk8u60   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码3 项目: openjdk-jdk8u   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码5 项目: openjdk-jdk9   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码6 项目: sling-samples   文件: HandlebarsScriptEngine.java
@Override
public Object eval(String script, ScriptContext context) throws ScriptException {
    final Resource resource = (Resource) context.getBindings(ScriptContext.ENGINE_SCOPE).get(SlingBindings.RESOURCE);
    final PrintWriter out = (PrintWriter) context.getBindings(ScriptContext.ENGINE_SCOPE).get(SlingBindings.OUT);

    try {
        final Handlebars handlebars = setupHandlebars();
        final Template template = handlebars.compileInline(script);
        out.println(template.apply(getData(resource)));
    } catch(IOException ioe) {
        final ScriptException up = new ScriptException("IOException in eval");
        up.initCause(ioe);
        throw up;
    }
    return null;
}
 
源代码7 项目: sling-samples   文件: HandlebarsScriptEngine.java
/** We might do this with a BindingsValuesProvider? */
private Map<?, ?> getData(Resource r) throws ScriptException {
    // Request resource.json and convert the result to Maps
    String jsonString = null;
    try {
        jsonString =
            new ServletInternalRequest(factory.getServletResolver(), r)
            .withExtension("json")
            .execute()
            .getResponseAsString()
        ;
    } catch(Exception e) {
        final ScriptException up = new ScriptException("Internal request failed");
        up.initCause(e);
        log.info("getData() failed", up);
        throw up;
    }
    final Map<?, ?> result = JsonReader.jsonToMaps(jsonString);
    log.debug("getData() returns a Map with {} keys", result.keySet().size());
    return result;
}
 
源代码8 项目: hottub   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码9 项目: openjdk-8-source   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码10 项目: openjdk-8   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码11 项目: jdk8u_nashorn   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e, final Global global) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        ne.initEcmaError(global);
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码12 项目: nashorn   文件: NashornScriptEngine.java
private static void throwAsScriptException(final Exception e) throws ScriptException {
    if (e instanceof ScriptException) {
        throw (ScriptException)e;
    } else if (e instanceof NashornException) {
        final NashornException ne = (NashornException)e;
        final ScriptException se = new ScriptException(
            ne.getMessage(), ne.getFileName(),
            ne.getLineNumber(), ne.getColumnNumber());
        se.initCause(e);
        throw se;
    } else if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        // wrap any other exception as ScriptException
        throw new ScriptException(e);
    }
}
 
源代码13 项目: sling-samples   文件: HandlebarsScriptEngine.java
@Override
public Object eval(Reader reader, ScriptContext context) throws ScriptException {
    try {
        return eval(IOUtils.toString(reader), context);
    } catch(IOException ioe) {
        final ScriptException up = new ScriptException("IOException in eval");
        up.initCause(ioe);
        throw up;
    }
}
 
源代码14 项目: kite   文件: ScriptEvaluator.java
private static void throwScriptCompilationException(String parseLocation, String msg, Throwable t) 
    throws ScriptException {
  
  if (t == null) {
    throw new ScriptException("Cannot compile script: " + parseLocation + " caused by " + msg);
  } else {
    ScriptException se = new ScriptException("Cannot compile script: " + parseLocation + " caused by " + msg);
    se.initCause(t);
    throw se;
  }
}
 
源代码15 项目: kite   文件: ScriptEvaluator.java
private static void throwScriptExecutionException(String parseLocation, Object[] params, Throwable e) 
    throws ScriptException {
  
  ScriptException se = new ScriptException("Cannot execute script: " + parseLocation + " for params " + Arrays.asList(params).toString());
  se.initCause(e);
  throw se;
}