mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:37:34 +00:00
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.
This commit is contained in:
parent
5d38cf4973
commit
4d8912a92b
48 changed files with 171 additions and 415 deletions
|
@ -246,9 +246,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(GlobalObject& global_
|
|||
// iv. Else,
|
||||
else {
|
||||
// 1. Let tag be ? ToString(kValue).
|
||||
tag = key_value.to_string(global_object);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
tag = TRY(key_value.to_string(global_object));
|
||||
}
|
||||
|
||||
// v. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
||||
|
|
|
@ -44,9 +44,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
return {};
|
||||
|
||||
// 3. Let code be ? ToString(code).
|
||||
auto code_string = code.to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto code_string = TRY_OR_DISCARD(code.to_string(global_object));
|
||||
code = js_string(vm, move(code_string));
|
||||
|
||||
// 4. Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code).
|
||||
|
|
|
@ -292,9 +292,7 @@ Value LocaleConstructor::construct(FunctionObject& new_target)
|
|||
// 9. Else,
|
||||
else {
|
||||
// a. Let tag be ? ToString(tag).
|
||||
tag = tag_value.to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
tag = TRY_OR_DISCARD(tag_value.to_string(global_object));
|
||||
}
|
||||
|
||||
// 10. Set options to ? CoerceOptionsToObject(options).
|
||||
|
@ -343,7 +341,7 @@ Value LocaleConstructor::construct(FunctionObject& new_target)
|
|||
// 24. If kn is not undefined, set kn to ! ToString(kn).
|
||||
// 25. Set opt.[[kn]] to kn.
|
||||
if (!kn.is_undefined())
|
||||
opt.kn = kn.to_string(global_object);
|
||||
opt.kn = TRY_OR_DISCARD(kn.to_string(global_object));
|
||||
|
||||
// 26. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
|
||||
// 27. If numberingSystem is not undefined, then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue