From 610afb21ace31283008e771c21fcffdc0582fc56 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 3 Jun 2022 17:12:25 +0300 Subject: [PATCH] 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. --- Userland/Utilities/js.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 37c10bde7a..9c2ca1d275 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -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(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(interpreter.global_object(), error.to_string()); } else { auto return_early = run_script_or_module(module_or_error.value()); if (return_early == ReturnEarly::Yes)