Example usage for javax.script ScriptException ScriptException

List of usage examples for javax.script ScriptException ScriptException

Introduction

In this page you can find the example usage for javax.script ScriptException ScriptException.

Prototype

public ScriptException(Exception e) 

Source Link

Document

Creates a ScriptException wrapping an Exception thrown by an underlying interpreter.

Usage

From source file:ste.xtest.js.BugFreeJavaScript.java

private void loadResourceScripts(final Context cx, final String[] scripts) throws ScriptException {
    InputStream is = null;//from   w w  w.  j  a  v  a 2  s.c  om
    try {
        for (String script : scripts) {
            is = BugFreeJavaScript.class.getResourceAsStream(script);
            if (is == null) {
                throw new FileNotFoundException(script + " not found in classpath");
            }
            cx.evaluateReader(scope, new InputStreamReader(is), script, 1, null);
            is.close();
            is = null;
        }
    } catch (Exception x) {
        throw new ScriptException("Error initializing the javascript engine: " + x.getMessage());
    } finally {
        Context.exit();
        if (is != null) {
            try {
                is.close();
            } catch (Exception x) {
            }
        }
        ;
    }
}