static volatile PersistableThrowable _handleException_lastException; static L _handleException_onException = synchroList(ll(f printStackTrace2)); static void _handleException(Throwable e) { _handleException_lastException = persistableThrowable(e); Throwable e2 = innerException(e); if (e2.getClass() == RuntimeException.class && eq(e2.getMessage(), "Thread cancelled.")) ret; for (O f : cloneList(_handleException_onException)) try { callF(f, e); } catch e3 { printStackTrace2(e3); // not using pcall here - it could lead to endless loops } }