diff --git a/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.cpp b/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.cpp index 91bee7aadf4..763a0513db6 100644 --- a/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.cpp +++ b/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.cpp @@ -42,4 +42,13 @@ ThrowCompletionOr ThrowableStringBuilder::append_code_point(u32 value) return {}; } +ThrowCompletionOr ThrowableStringBuilder::to_string() const +{ + auto result = StringBuilder::to_string(); + if (result.is_error()) + return m_vm.throw_completion(ErrorType::NotEnoughMemoryToAllocate, length()); + + return result.release_value(); +} + } diff --git a/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h b/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h index 08ca7eb2fab..39d5e91054a 100644 --- a/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h +++ b/Userland/Libraries/LibJS/Runtime/ThrowableStringBuilder.h @@ -23,6 +23,7 @@ public: ThrowCompletionOr append(StringView); ThrowCompletionOr append(Utf16View const&); ThrowCompletionOr append_code_point(u32 value); + ThrowCompletionOr to_string() const; private: VM& m_vm;