Search in sources :

Example 1 with ScriptingException

use of sirius.pasta.noodle.ScriptingException in project sirius-biz by scireum.

the class Scripting method handleExecTask.

private void handleExecTask(JSONObject event) {
    String nodeName = event.getString(TASK_NODE);
    String jobNumber = event.getString(TASK_JOB);
    if (!ALL_NODES.equals(nodeName) && !Strings.areEqual(CallContext.getNodeName(), nodeName)) {
        return;
    }
    Watch watch = Watch.start();
    logInTranscript(jobNumber, Strings.apply("Starting execution on %s (Thread Id: %s / Thread Name: %s)", CallContext.getNodeName(), Thread.currentThread().getId(), Thread.currentThread().getName()));
    try {
        Callable callable = compileScript(event);
        TaskContext.get().setAdapter(new JobTaskContextAdapter(this, jobNumber));
        callable.call(new SimpleEnvironment());
    } catch (CompileException | ScriptingException | HandledException e) {
        logInTranscript(jobNumber, e.getMessage());
    } catch (Exception e) {
        logInTranscript(jobNumber, Exceptions.handle(Pasta.LOG, e).getMessage());
    }
    logInTranscript(jobNumber, Strings.apply("Execution completed (%s)", watch.duration()));
}
Also used : HandledException(sirius.kernel.health.HandledException) SimpleEnvironment(sirius.pasta.noodle.SimpleEnvironment) Watch(sirius.kernel.commons.Watch) CompileException(sirius.pasta.noodle.compiler.CompileException) Callable(sirius.pasta.noodle.Callable) HandledException(sirius.kernel.health.HandledException) ScriptingException(sirius.pasta.noodle.ScriptingException) CompileException(sirius.pasta.noodle.compiler.CompileException) ScriptingException(sirius.pasta.noodle.ScriptingException)

Aggregations

Watch (sirius.kernel.commons.Watch)1 HandledException (sirius.kernel.health.HandledException)1 Callable (sirius.pasta.noodle.Callable)1 ScriptingException (sirius.pasta.noodle.ScriptingException)1 SimpleEnvironment (sirius.pasta.noodle.SimpleEnvironment)1 CompileException (sirius.pasta.noodle.compiler.CompileException)1