1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

LibJS+LibWeb: Move the macro to convert ENOMEM to an exception to LibJS

Move the macro to LibJS and change it to return a throw completion
instead of a WebIDL exception. This will let us use this macro within
LibJS to handle OOM conditions.
This commit is contained in:
Timothy Flynn 2023-01-07 12:14:54 -05:00 committed by Linus Groh
parent ba97f6a0d3
commit d8044c5358
15 changed files with 118 additions and 93 deletions

View file

@ -8,6 +8,7 @@
#include <AK/DeprecatedString.h>
#include <AK/Utf8View.h>
#include <AK/Vector.h>
#include <LibJS/Runtime/Completion.h>
#include <LibTextCodec/Decoder.h>
#include <LibWeb/Bindings/WorkerGlobalScopePrototype.h>
#include <LibWeb/Forward.h>
@ -137,7 +138,7 @@ WebIDL::ExceptionOr<DeprecatedString> WorkerGlobalScope::btoa(DeprecatedString c
// Otherwise, the user agent must convert data to a byte sequence whose nth byte is the eight-bit representation of the nth code point of data,
// and then must apply forgiving-base64 encode to that byte sequence and return the result.
return TRY_OR_RETURN_OOM(realm(), encode_base64(byte_string.span())).to_deprecated_string();
return TRY_OR_THROW_OOM(vm(), encode_base64(byte_string.span())).to_deprecated_string();
}
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob