Search in sources :

Example 1 with JVMStackTracer

use of php.runtime.util.JVMStackTracer in project jphp by jphp-compiler.

the class Environment method catchUncaught.

public boolean catchUncaught(Exception e, boolean retry) {
    if (e instanceof UncaughtException)
        return catchUncaught((UncaughtException) e);
    else if (e instanceof DieException) {
        System.exit(((DieException) e).getExitCode());
        return true;
    } else if (e instanceof ErrorException) {
        ErrorException er = (ErrorException) e;
        getErrorReportHandler().onFatal(er);
        JVMStackTracer tracer = scope.getStackTracer(e);
        int i = 0;
        for (JVMStackTracer.Item el : tracer) {
            if (!el.isInternal()) {
                echo("\n\t #" + (i++) + " " + el);
            }
        }
        echo("\n");
        for (JVMStackTracer.Item el : tracer) {
            if (!el.isSystem()) {
                echo("\n\t " + (el.isInternal() ? "" : "->") + " " + el);
            }
        }
        return true;
    } else if (e instanceof FinallyException) {
        // nop
        return true;
    } else if (e instanceof BaseBaseException) {
        BaseBaseException be = (BaseBaseException) e;
        if (exceptionHandler != null) {
            try {
                exceptionHandler.onException(this, be);
            } catch (BaseBaseException _e) {
                if (retry) {
                    throw new RuntimeException(_e);
                } else {
                    catchUncaught(_e, true);
                }
            } catch (Throwable throwable) {
                throw new RuntimeException(throwable);
            }
            return true;
        } else {
            try {
                ExceptionHandler.DEFAULT.onException(this, be);
                return true;
            } catch (Throwable throwable) {
                throw new RuntimeException(throwable);
            }
        }
    } else {
        throw new RuntimeException(e);
    }
}
Also used : JVMStackTracer(php.runtime.util.JVMStackTracer) ErrorException(php.runtime.exceptions.support.ErrorException) BaseBaseException(php.runtime.lang.exception.BaseBaseException)

Aggregations

ErrorException (php.runtime.exceptions.support.ErrorException)1 BaseBaseException (php.runtime.lang.exception.BaseBaseException)1 JVMStackTracer (php.runtime.util.JVMStackTracer)1