summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Encoding
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2022-07-22 21:01:36 +0200
committerLinus Groh <mail@linusgroh.de>2022-07-22 23:08:28 +0100
commit9fe12c1851dbfe675d77d62dd2e89a702ab543d7 (patch)
treea146131ee49543eba7605c7c6e58cbd44a722c8b /Userland/Libraries/LibWeb/Encoding
parent7a2bef7fe12b8058ab0e44634f47b44e6de9aa67 (diff)
downloadserenity-9fe12c1851dbfe675d77d62dd2e89a702ab543d7.zip
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().
Diffstat (limited to 'Userland/Libraries/LibWeb/Encoding')
-rw-r--r--Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
index 28575cd9c7..3e0e3b24ef 100644
--- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
+++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
@@ -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() });
}
}