mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
js: Handle exceptions thrown during value printing
If an exception was thrown while printing the last computed value in the REPL, it would always assert on next input. Something like this would always assert: > a=[];Object.defineProperty(a,"0",{get:()=>{throw ""}}) > 1 + 2
This commit is contained in:
parent
c33d50872e
commit
a061bd2ab9
Notes:
sideshowbarker
2024-07-18 22:46:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a061bd2ab96
1 changed files with 9 additions and 4 deletions
|
@ -467,7 +467,7 @@ static bool parse_and_run(JS::Interpreter& interpreter, const StringView& source
|
|||
interpreter.run(interpreter.global_object(), *program);
|
||||
}
|
||||
|
||||
if (vm->exception()) {
|
||||
auto handle_exception = [&] {
|
||||
out("Uncaught exception: ");
|
||||
print(vm->exception()->value());
|
||||
auto trace = vm->exception()->trace();
|
||||
|
@ -493,10 +493,15 @@ static bool parse_and_run(JS::Interpreter& interpreter, const StringView& source
|
|||
}
|
||||
}
|
||||
vm->clear_exception();
|
||||
return false;
|
||||
}
|
||||
if (s_print_last_result)
|
||||
};
|
||||
if (vm->exception())
|
||||
handle_exception();
|
||||
|
||||
if (s_print_last_result) {
|
||||
print(vm->last_value());
|
||||
if (vm->exception())
|
||||
handle_exception();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue