mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 05:15:07 +00:00
LibWeb: Let get_buffer_source_copy() return ErrorOr instead of Optional
This is a minor refactor of IDL::get_buffer_source_copy() letting it return ErrorOr<ByteBuffer> instead of Optional<ByteBuffer>. This also updates all places that use IDL::get_buffer_source_copy().
This commit is contained in:
parent
7a2bef7fe1
commit
9fe12c1851
5 changed files with 15 additions and 18 deletions
|
@ -17,11 +17,11 @@ DOM::ExceptionOr<String> TextDecoder::decode(JS::Handle<JS::Object> const& input
|
|||
{
|
||||
// FIXME: Implement the streaming stuff.
|
||||
|
||||
auto data_buffer = Bindings::IDL::get_buffer_source_copy(*input.cell());
|
||||
if (!data_buffer.has_value())
|
||||
auto data_buffer_or_error = Bindings::IDL::get_buffer_source_copy(*input.cell());
|
||||
if (data_buffer_or_error.is_error())
|
||||
return DOM::OperationError::create("Failed to copy bytes from ArrayBuffer");
|
||||
|
||||
return m_decoder.to_utf8({ data_buffer->data(), data_buffer->size() });
|
||||
auto& data_buffer = data_buffer_or_error.value();
|
||||
return m_decoder.to_utf8({ data_buffer.data(), data_buffer.size() });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue