mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibJS: Add ThrowableStringBuilder::to_string to create a new String
This wraps around the base class method to throw an OOM completion.
This commit is contained in:
committed by
Linus Groh
parent
3ad1f250e7
commit
79e81e8a15
@@ -42,4 +42,13 @@ ThrowCompletionOr<void> ThrowableStringBuilder::append_code_point(u32 value)
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<String> ThrowableStringBuilder::to_string() const
|
||||
{
|
||||
auto result = StringBuilder::to_string();
|
||||
if (result.is_error())
|
||||
return m_vm.throw_completion<InternalError>(ErrorType::NotEnoughMemoryToAllocate, length());
|
||||
|
||||
return result.release_value();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
ThrowCompletionOr<void> append(StringView);
|
||||
ThrowCompletionOr<void> append(Utf16View const&);
|
||||
ThrowCompletionOr<void> append_code_point(u32 value);
|
||||
ThrowCompletionOr<String> to_string() const;
|
||||
|
||||
private:
|
||||
VM& m_vm;
|
||||
|
||||
Reference in New Issue
Block a user