From 9a5a4302d993cc5867dfcc0f364ea57bc59faf8b Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 12 Feb 2023 21:36:02 -0500 Subject: [PATCH] LibJS: Convert PropertyDescriptor's formatter to String And generally propagate OOM. --- .../LibJS/Runtime/PropertyDescriptor.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h index 439e10f984..a395340258 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -49,20 +50,20 @@ template<> struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, JS::PropertyDescriptor const& property_descriptor) { - Vector parts; + Vector parts; if (property_descriptor.value.has_value()) - parts.append(DeprecatedString::formatted("[[Value]]: {}", property_descriptor.value->to_deprecated_string_without_side_effects())); + TRY(parts.try_append(TRY(String::formatted("[[Value]]: {}", TRY(property_descriptor.value->to_string_without_side_effects()))))); if (property_descriptor.get.has_value()) - parts.append(DeprecatedString::formatted("[[Get]]: JS::Function* @ {:p}", *property_descriptor.get)); + TRY(parts.try_append(TRY(String::formatted("[[Get]]: JS::Function* @ {:p}", *property_descriptor.get)))); if (property_descriptor.set.has_value()) - parts.append(DeprecatedString::formatted("[[Set]]: JS::Function* @ {:p}", *property_descriptor.set)); + TRY(parts.try_append(TRY(String::formatted("[[Set]]: JS::Function* @ {:p}", *property_descriptor.set)))); if (property_descriptor.writable.has_value()) - parts.append(DeprecatedString::formatted("[[Writable]]: {}", *property_descriptor.writable)); + TRY(parts.try_append(TRY(String::formatted("[[Writable]]: {}", *property_descriptor.writable)))); if (property_descriptor.enumerable.has_value()) - parts.append(DeprecatedString::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable)); + TRY(parts.try_append(TRY(String::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable)))); if (property_descriptor.configurable.has_value()) - parts.append(DeprecatedString::formatted("[[Configurable]]: {}", *property_descriptor.configurable)); - return Formatter::format(builder, DeprecatedString::formatted("PropertyDescriptor {{ {} }}", DeprecatedString::join(", "sv, parts))); + TRY(parts.try_append(TRY(String::formatted("[[Configurable]]: {}", *property_descriptor.configurable)))); + return Formatter::format(builder, TRY(String::formatted("PropertyDescriptor {{ {} }}", TRY(String::join(", "sv, parts))))); } };