Examples of ScriptException


Examples of javax.script.ScriptException

  private ScriptEvaluator createNewScriptEvaluator(String languageName) throws ScriptException {

    ScriptEngine engine = new ScriptEngineManager().getEngineByName( languageName );

    if ( engine == null ) {
      throw new ScriptException( "No JSR 223 script engine found for language \"" + languageName + "\"." );
    }

    return new ScriptEvaluator( engine );
  }
View Full Code Here

Examples of javax.script.ScriptException

            globalClosures.setBundle(bundle);
        } catch (ClassCastException cce) { /*ignore.*/ }

        try {
            final Class clazz = getScriptClass(script);
            if (null == clazz) throw new ScriptException("Script class is null");
            return eval(clazz, context);
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine());
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

Examples of javax.script.ScriptException

    @Override
    public CompiledScript compile(final String scriptSource) throws ScriptException {
        try {
            return new GroovyCompiledScript(this, getScriptClass(scriptSource));
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(),
                    e.getSourceLocator(), e.getLine());
        } catch (IOException e) {
            throw new ScriptException(e);
        } catch (CompilationFailedException ee) {
            throw new ScriptException(ee);
        }
    }
View Full Code Here

Examples of javax.script.ScriptException

                    }
                }
            });
            return scriptObject.run();
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

Examples of javax.script.ScriptException

                return InvokerHelper.invokeMethod(thiz, name, args);
            }
        } catch (MissingMethodException mme) {
            throw new NoSuchMethodException(mme.getMessage());
        } catch (Exception e) {
            throw new ScriptException(e);
        }
        return callGlobal(name, args);
    }
View Full Code Here

Examples of javax.script.ScriptException

        try {
            while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
                buf.append(arr, 0, numChars);
            }
        } catch (IOException exp) {
            throw new ScriptException(exp);
        }
        return buf.toString();
    }
View Full Code Here

Examples of javax.script.ScriptException

import junit.framework.TestCase;

public class ScriptExceptionTest extends TestCase {

    public void testException1(){
        ScriptException ex = new ScriptException("");
        try {
            throw ex;
        } catch (ScriptException e) {
            assertEquals(-1, e.getLineNumber());
            assertEquals(-1, e.getColumnNumber());
View Full Code Here

Examples of javax.script.ScriptException

            assertNull(e.getFileName()); // this is not defined by the spec. or the Java 6 API
        }
    }

    public void testException2(){
        ScriptException ex = new ScriptException(new Exception());
        try {
            throw ex;
        } catch (ScriptException e) {
            assertEquals(-1, e.getLineNumber());
            assertEquals(-1, e.getColumnNumber());
View Full Code Here

Examples of javax.script.ScriptException

        }
    }

    public void testException3(){
        final String fileName = "file";
        ScriptException ex = new ScriptException("test", fileName, 10);
        try {
            throw ex;
        } catch (ScriptException e) {
            assertEquals(10, e.getLineNumber());
            assertEquals(-1, e.getColumnNumber());
View Full Code Here

Examples of javax.script.ScriptException

        }
    }

    public void testException4(){
        final String fileName = "file";
        ScriptException ex = new ScriptException("test", fileName, 10, 30);
        try {
            throw ex;
        } catch (ScriptException e) {
            assertEquals(10, e.getLineNumber());
            assertEquals(30, e.getColumnNumber());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.