summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-12 17:49:01 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-13 09:55:10 +0100
commit4d8912a92b4378d34a06806b3126c8463bdbdcf5 (patch)
tree9d9ed3594c1512756d1c9337794a29a3d5965b5c /Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
parent5d38cf497331ba9a533d2da64d91f7044b3ee87f (diff)
downloadserenity-4d8912a92b4378d34a06806b3126c8463bdbdcf5.zip
LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is not a standard AO and should be refactored out of existence eventually.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index c108374734..1f0ed8a418 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -42,9 +42,7 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
auto* error = TRY_OR_DISCARD(ordinary_create_from_constructor<Error>(global_object, new_target, &GlobalObject::error_prototype));
if (!vm.argument(0).is_undefined()) {
- auto message = vm.argument(0).to_string(global_object);
- if (vm.exception())
- return {};
+ auto message = TRY_OR_DISCARD(vm.argument(0).to_string(global_object));
MUST(error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)));
}
@@ -89,9 +87,7 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
global_object, new_target, &GlobalObject::snake_name##_prototype)); \
\
if (!vm.argument(0).is_undefined()) { \
- auto message = vm.argument(0).to_string(global_object); \
- if (vm.exception()) \
- return {}; \
+ auto message = TRY_OR_DISCARD(vm.argument(0).to_string(global_object)); \
MUST(error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message))); \
} \
\