Examples of ScriptException


Examples of com.baasbox.dao.exception.ScriptException

        return result;
    }

    private static void validateBody(JsonNode body) throws ScriptException{
        if (body == null){
            throw new ScriptException("missing body");
        }
        JsonNode name = body.get(ScriptsDao.NAME);
        if (name == null || (!name.isTextual())|| name.asText().trim().length()==0) {
            throw new ScriptException("missing required 'name' property");
        }
        JsonNode code = body.get(ScriptsDao.CODE);
        if (code == null||(!code.isTextual())||code.asText().trim().length()==0) {
            throw new ScriptException("missing required 'code' property");
        }
    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptException

    final Throwable cause = event.getException().getCause();
    if (cause instanceof FailingHttpStatusCodeException)
      return true;
    else if (cause instanceof ScriptException)
    {
      final ScriptException se = (ScriptException) cause;
      return se.getPage() != null; // should probably always be the case
      // but a (now fixed) bug in HtmlUnit-1.14 causes an exception during init
      // of the JavaScriptEngine and no page is available
    }
    return false;
  }
View Full Code Here

Examples of com.scratchdisk.script.ScriptException

        } else if (name.startsWith("__init__")) {
          try {
            ScriptEngine engine =
                ScriptEngine.getEngineByFile(file);
            if (engine == null)
              throw new ScriptException(
                  "Unable to find script engine for " + file);
            execute(file, engine.createScope());
          } catch (Exception e) {
            reportError(e);
          }
View Full Code Here

Examples of de.danet.an.workflow.internalapi.ScriptException

    return new Date (millis.longValue());
      }
      return (Serializable)res;
  } catch (JavaScriptException e) {
      logger.error (e.getMessage (), e);
      throw new ScriptException
    (e.getMessage (),
     (e.getValue() instanceof Throwable)
     ? (Throwable)e.getValue() : e);
        } catch (SAXException e) {
            logger.error (e.getMessage (), e);
            throw new ScriptException (e.getMessage (), e);
  } finally {
      Context.exit();
  }
    }
View Full Code Here

Examples of javax.script.ScriptException

          map.put((String)key, bindings.get(key));
        }
        }
      return this.expression.execute(map);
      } catch (Exception e) {
        throw new ScriptException(e);
      }
  }
View Full Code Here

Examples of javax.script.ScriptException

    {
      return ((Compilable)compiler).compile(script);
    }
    catch(ClassCastException ex)
    {
      throw new ScriptException("Script engine for '"
                                + language + "' doesn't support CompiledScript." );
    }
   }
View Full Code Here

Examples of javax.script.ScriptException

       return compiler;

     // No compiler created for this language. Lookup in ScriptManager
     compiler = (Compilable)scriptEngineManager.getEngineByName(language);
     if( compiler == null )
       throw new ScriptException("No compiler registered under name '" + language + "'.");

     // Add in cache
     compilers.put(language, compiler);
     return compiler;
   }
View Full Code Here

Examples of javax.script.ScriptException

      {
      return evaluator.evaluate(script, context, Object.class, null, null);
      }
     catch (ELException ex)
      {
      throw new ScriptException(ex);
      }
   }
View Full Code Here

Examples of javax.script.ScriptException

        } catch (JavaScriptException t) {

            // prevent variables to be pushed back in case of errors
            isTopLevelCall = false;

            final ScriptException se = new ScriptException(t.details(),
                t.sourceName(), t.lineNumber());

            // log the script stack trace
            ((Logger) bindings.get(SlingBindings.LOG)).error(t.getScriptStackTrace());

            // set the exception cause
            Object value = t.getValue();
            if (value != null) {
                if (value instanceof Wrapper) {
                    value = ((Wrapper) value).unwrap();
                }
                if (value instanceof Throwable) {
                    se.initCause((Throwable) value);
                }
            }

            // if the cause could not be set, overwrite the stack trace
            if (se.getCause() == null) {
                se.setStackTrace(t.getStackTrace());
            }

            throw se;

        } catch (Throwable t) {

            // prevent variables to be pushed back in case of errors
            isTopLevelCall = false;

            final ScriptException se = new ScriptException(
                "Failure running script " + scriptName + ": " + t.getMessage());
            se.initCause(t);
            throw se;

        } finally {

            // if we are the top call (the Context is now null) we have to
View Full Code Here

Examples of javax.script.ScriptException

            throws ScriptException {
        Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);

        SlingScriptHelper helper = (SlingScriptHelper) bindings.get(SlingBindings.SLING);
        if (helper == null) {
            throw new ScriptException("SlingScriptHelper missing from bindings");
        }

        // ensure GET request
        if (helper.getRequest() != null && !"GET".equals(helper.getRequest().getMethod())) {
            throw new ScriptException(
                "JRuby scripting only supports GET requests");
        }

        final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        try {
          Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
            StringBuffer scriptString = new StringBuffer();
            BufferedReader bufferedScript = new BufferedReader(script);
            String nextLine = bufferedScript.readLine();
            while (nextLine != null) {
                scriptString.append(nextLine);
                scriptString.append("\n");
                nextLine = bufferedScript.readLine();
            }

            IRubyObject scriptRubyString = JavaEmbedUtils.javaToRuby(runtime,
                scriptString.toString());
            IRubyObject erb = (IRubyObject) JavaEmbedUtils.invokeMethod(
                runtime, erbModule, "new", new Object[] { scriptRubyString },
                IRubyObject.class);

            JavaEmbedUtils.invokeMethod(runtime, erb, "set_props",
                new Object[] { JavaEmbedUtils.javaToRuby(runtime, bindings) },
                IRubyObject.class);

            IRubyObject binding = (IRubyObject) JavaEmbedUtils.invokeMethod(
                runtime, erb, "send", new Object[] { bindingSym },
                IRubyObject.class);

            scriptContext.getWriter().write(
                (String) JavaEmbedUtils.invokeMethod(runtime, erb, "result",
                    new Object[] { binding }, String.class));
        } catch (Throwable t) {
          final ScriptException ex = new ScriptException("Failure running Ruby script:" + t);
          ex.initCause(t);
          throw ex;
        } finally {
          Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
        return null;
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.