mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +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:
parent
3ad1f250e7
commit
79e81e8a15
Notes:
sideshowbarker
2024-07-17 01:41:31 +09:00
Author: https://github.com/trflynn89
Commit: 79e81e8a15
Pull-request: https://github.com/SerenityOS/serenity/pull/17014
Reviewed-by: https://github.com/linusg ✅
2 changed files with 10 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue