summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/StringConstructor.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/StringConstructor.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/StringConstructor.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringConstructor.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
index 7396373d87..74d79441dc 100644
--- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -94,9 +94,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
StringBuilder builder;
for (size_t i = 0; i < literal_segments; ++i) {
auto next_key = String::number(i);
- auto next_segment = TRY_OR_DISCARD(raw->get(next_key)).to_string(global_object);
- if (vm.exception())
- return {};
+ auto next_segment_value = TRY_OR_DISCARD(raw->get(next_key));
+ auto next_segment = TRY_OR_DISCARD(next_segment_value.to_string(global_object));
builder.append(next_segment);
@@ -105,9 +104,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
if (i < number_of_substituions) {
auto next = vm.argument(i + 1);
- auto next_sub = next.to_string(global_object);
- if (vm.exception())
- return {};
+ auto next_sub = TRY_OR_DISCARD(next.to_string(global_object));
builder.append(next_sub);
}
}