mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 10:36:02 +00:00
LibTextCodec+Everywhere: Return Optional<Decoder&> from decoder_for()
This commit is contained in:
parent
2f4c463920
commit
f2a9426885
Notes:
sideshowbarker
2024-07-17 00:01:08 +09:00
Author: https://github.com/AtkinsSJ
Commit: f2a9426885
Pull-request: https://github.com/SerenityOS/serenity/pull/17511
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/nico
16 changed files with 42 additions and 39 deletions
|
@ -15,7 +15,7 @@ namespace Web::Encoding {
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, DeprecatedFlyString encoding)
|
||||
{
|
||||
auto decoder = TextCodec::decoder_for(encoding);
|
||||
if (!decoder)
|
||||
if (!decoder.has_value())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Invalid encoding {}", encoding) };
|
||||
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<TextDecoder>(realm, realm, *decoder, move(encoding), false, false));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue