mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +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:
parent
ba97f6a0d3
commit
d8044c5358
Notes:
sideshowbarker
2024-07-17 11:30:54 +09:00
Author: https://github.com/trflynn89
Commit: d8044c5358
Pull-request: https://github.com/SerenityOS/serenity/pull/16895
Reviewed-by: https://github.com/linusg
15 changed files with 118 additions and 93 deletions
|
@ -11,10 +11,23 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/Try.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibJS/Runtime/ErrorTypes.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
#define TRY_OR_THROW_OOM(vm, expression) \
|
||||
({ \
|
||||
/* Ignore -Wshadow to allow nesting the macro. */ \
|
||||
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
|
||||
auto _temporary_result = (expression)); \
|
||||
if (_temporary_result.is_error()) { \
|
||||
VERIFY(_temporary_result.error().code() == ENOMEM); \
|
||||
return vm.throw_completion<JS::InternalError>(JS::ErrorType::OutOfMemory); \
|
||||
} \
|
||||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
||||
// 6.2.3 The Completion Record Specification Type, https://tc39.es/ecma262/#sec-completion-record-specification-type
|
||||
class [[nodiscard]] Completion {
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue