1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

js: Create throw completions instead of raw error values on SyntaxError

This ensures that js's error printing logic is used instead of the
generic value printing logic, which then lets eshost correctly parse
thrown SyntaxErrors using the normal LibJS exception format.
This commit is contained in:
Idan Horowitz 2022-06-03 17:12:25 +03:00 committed by Linus Groh
parent a67a7229f8
commit 610afb21ac
Notes: sideshowbarker 2024-07-17 10:29:01 +09:00

View file

@ -1110,7 +1110,7 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
if (!hint.is_empty())
outln("{}", hint);
outln(error.to_string());
result = JS::SyntaxError::create(interpreter.global_object(), error.to_string());
result = interpreter.vm().throw_completion<JS::SyntaxError>(interpreter.global_object(), error.to_string());
} else {
auto return_early = run_script_or_module(script_or_error.value());
if (return_early == ReturnEarly::Yes)
@ -1124,7 +1124,7 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
if (!hint.is_empty())
outln("{}", hint);
outln(error.to_string());
result = JS::SyntaxError::create(interpreter.global_object(), error.to_string());
result = interpreter.vm().throw_completion<JS::SyntaxError>(interpreter.global_object(), error.to_string());
} else {
auto return_early = run_script_or_module(module_or_error.value());
if (return_early == ReturnEarly::Yes)