return null; // success
} else {
// fail (AssertionError) or error
// decode as Java's error and rethrow it
Source code = new Source(sourceName, compiled.length() != 0 ? compiled : script.write());
Throwable throwable = ClientStackTrace.decode((String) result, code);
if (throwable instanceof AssertionError || throwable instanceof InternalError) {
dumpCode(code);
throwable = new PowerAssertOffError(throwable);
}
throw I.quiet(throwable);
}
} catch (ScriptException e) {
dumpCode(source);
// script parse error (translation fails) or runtime error
Source code = new Source(sourceName, script.write());
if (e.getScriptSourceCode() == null) {
Throwable cause = e.getCause();
if (cause instanceof EcmaError) {
throw new ScriptRuntimeError(code, (EcmaError) cause);
} else {
// error in boot.js
int number = e.getFailingLineNumber();
if (number != -1) {
TranslationError error = new TranslationError(e);
error.write(code.findBlock(number));
throw error;
} else {
throw I.quiet(e);
}
}
} else {
// error in test script
TranslationError error = new TranslationError(e);
error.write(code.findBlock(e.getFailingLineNumber()));
throw error;
}
} catch (Throwable e) {
throw I.quiet(e);
}