Search in sources :

Example 1 with CatchBlockImpl

use of lucee.runtime.exp.CatchBlockImpl in project Lucee by lucee.

the class CFMLSpoolerTaskListener method listen.

@Override
public void listen(Config config, Exception e) {
    if (!(config instanceof ConfigWeb))
        return;
    ConfigWeb cw = (ConfigWeb) config;
    PageContext pc = ThreadLocalPageContext.get();
    boolean pcCreated = false;
    if (pc == null) {
        pcCreated = true;
        Pair[] parr = new Pair[0];
        DevNullOutputStream os = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
        pc = ThreadUtil.createPageContext(cw, os, "localhost", "/", "", new Cookie[0], parr, null, parr, new StructImpl(), true, -1);
        pc.setRequestTimeout(config.getRequestTimeout().getMillis());
    }
    try {
        Struct args = new StructImpl();
        long l = task.lastExecution();
        if (l > 0)
            args.set("lastExecution", new DateTimeImpl(pc, l, true));
        l = task.nextExecution();
        if (l > 0)
            args.set("nextExecution", new DateTimeImpl(pc, l, true));
        args.set("created", new DateTimeImpl(pc, task.getCreation(), true));
        args.set(KeyConstants._id, task.getId());
        args.set(KeyConstants._type, task.getType());
        args.set(KeyConstants._detail, task.detail());
        args.set(KeyConstants._tries, task.tries());
        args.set("remainingtries", e == null ? 0 : task.getPlans().length - task.tries());
        args.set("closed", task.closed());
        args.set("passed", e == null);
        if (e != null)
            args.set("exception", new CatchBlockImpl(Caster.toPageException(e)));
        Struct curr = new StructImpl();
        args.set("caller", curr);
        curr.set("template", currTemplate.template);
        curr.set("line", new Double(currTemplate.line));
        Struct adv = new StructImpl();
        args.set("advanced", adv);
        adv.set("exceptions", task.getExceptions());
        adv.set("executedPlans", task.getPlans());
        _listen(pc, args);
    } catch (PageException pe) {
        SystemOut.printDate(pe);
    } finally {
        if (pcCreated)
            ThreadLocalPageContext.release();
    }
}
Also used : Cookie(javax.servlet.http.Cookie) PageException(lucee.runtime.exp.PageException) ConfigWeb(lucee.runtime.config.ConfigWeb) DevNullOutputStream(lucee.commons.io.DevNullOutputStream) Struct(lucee.runtime.type.Struct) StructImpl(lucee.runtime.type.StructImpl) CatchBlockImpl(lucee.runtime.exp.CatchBlockImpl) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) Pair(lucee.commons.lang.Pair)

Aggregations

Cookie (javax.servlet.http.Cookie)1 DevNullOutputStream (lucee.commons.io.DevNullOutputStream)1 Pair (lucee.commons.lang.Pair)1 PageContext (lucee.runtime.PageContext)1 ConfigWeb (lucee.runtime.config.ConfigWeb)1 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)1 CatchBlockImpl (lucee.runtime.exp.CatchBlockImpl)1 PageException (lucee.runtime.exp.PageException)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1 DateTimeImpl (lucee.runtime.type.dt.DateTimeImpl)1