1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 07:04:59 +00:00

LibJS+Everywhere: Convert JS::Error to String

This includes an Error::create overload to create an Error from a UTF-8
StringView. If creating a String from that view fails, the factory will
return an OOM InternalError instead. VM::throw_completion can also make
use of this overload via its perfect forwarding.
This commit is contained in:
Timothy Flynn 2023-02-16 14:09:11 -05:00 committed by Tim Flynn
parent 153b793638
commit 88814acbd3
36 changed files with 198 additions and 151 deletions

View file

@ -90,7 +90,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, JS::GCPtr<JS::En
// 5. If script's error to rethrow is not null, then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]: script's error to rethrow, [[Target]]: empty }.
if (m_error_to_rethrow.has_value()) {
evaluation_status = vm.throw_completion<JS::SyntaxError>(m_error_to_rethrow.value().to_deprecated_string());
evaluation_status = vm.throw_completion<JS::SyntaxError>(TRY_OR_THROW_OOM(vm, m_error_to_rethrow.value().to_string()));
} else {
auto timer = Core::ElapsedTimer::start_new();