diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-12 17:49:01 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-13 09:55:10 +0100 |
commit | 4d8912a92b4378d34a06806b3126c8463bdbdcf5 (patch) | |
tree | 9d9ed3594c1512756d1c9337794a29a3d5965b5c /Userland/Libraries/LibJS/Runtime/StringConstructor.cpp | |
parent | 5d38cf497331ba9a533d2da64d91f7044b3ee87f (diff) | |
download | serenity-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.cpp | 9 |
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); } } |