Search in sources :

Example 1 with LocException

use of catdata.aql.exp.LocException in project fql by CategoricalData.

the class CodeEditor method run.

@Override
public // TODO aql put this on another thread besides the event dispatch thread
void run() {
    String program = topArea.getText();
    Progg init;
    Env env;
    init = tryParse(program);
    if (init == null) {
        return;
    }
    long start;
    long middle;
    try {
        start = System.currentTimeMillis();
        env = makeEnv(program, init);
        middle = System.currentTimeMillis();
        toDisplay = "Computation finished, creating viewer... (max " + init.timeout() + " seconds)";
        DateFormat format = DateFormat.getTimeInstance();
        String foo2 = title;
        foo2 += " - " + format.format(new Date(start));
        foo2 += " - " + format.format(new Date(start));
        String foo = foo2;
        long t = (Long) init.timeout() * 1000;
        display = Util.timeout(() -> makeDisplay(foo, init, env, start, middle), t);
        // display = makeDisplay(foo, init, env, start, middle);
        if (display.exn() == null) {
            // "Done";
            toDisplay = textFor(env);
            // "Done");
            respArea.setText(textFor(env));
        } else {
            throw display.exn();
        }
    } catch (LineException e) {
        toDisplay = "Error in " + e.kind + " " + e.decl + ": " + e.getLocalizedMessage();
        respArea.setText(toDisplay);
        e.printStackTrace();
        Integer theLine = init.getLine(e.decl);
        setCaretPos(theLine);
    } catch (LocException e) {
        toDisplay = "Error: " + e.getLocalizedMessage();
        respArea.setText(toDisplay);
        e.printStackTrace();
        setCaretPos(e.loc);
    } catch (Throwable re) {
        toDisplay = "Error: " + re.getLocalizedMessage();
        respArea.setText(toDisplay);
        re.printStackTrace();
    }
    interruptAndNullify();
}
Also used : LocException(catdata.aql.exp.LocException) DateFormat(java.text.DateFormat) LineException(catdata.LineException) Date(java.util.Date)

Aggregations

LineException (catdata.LineException)1 LocException (catdata.aql.exp.LocException)1 DateFormat (java.text.DateFormat)1 Date (java.util.Date)1