mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibJS: Repurpose MUST_OR_THROW_OOM to propagate general internal errors
There are now no users of the MUST_OR_THROW_OOM macro. Let's rename this macro to indicate it may be used to propagate any internal error (such as the call stack limit error) in places that would otherwise crash due to a MUST/VERIFY invocation. Note there's no actual functional change here, as we weren't able to ensure the internal error was an OOM error previously.
This commit is contained in:
parent
4c51602437
commit
b91a0f5403
Notes:
github-actions[bot]
2025-02-05 13:06:06 +00:00
Author: https://github.com/trflynn89
Commit: b91a0f5403
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3450
Reviewed-by: https://github.com/shannonbooth ✅
1 changed files with 17 additions and 18 deletions
|
@ -31,24 +31,23 @@ namespace JS {
|
|||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
||||
#define MUST_OR_THROW_OOM(...) \
|
||||
({ \
|
||||
/* Ignore -Wshadow to allow nesting the macro. */ \
|
||||
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
|
||||
auto&& _temporary_result = (__VA_ARGS__)); \
|
||||
if (_temporary_result.is_error()) { \
|
||||
auto _completion = _temporary_result.release_error(); \
|
||||
\
|
||||
/* We can't explicitly check for OOM because InternalError does not store the ErrorType */ \
|
||||
VERIFY(_completion.value().has_value()); \
|
||||
VERIFY(_completion.value()->is_object()); \
|
||||
VERIFY(::AK::is<JS::InternalError>(_completion.value()->as_object())); \
|
||||
\
|
||||
return _completion; \
|
||||
} \
|
||||
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
|
||||
"Do not return a reference from a fallible expression"); \
|
||||
_temporary_result.release_value(); \
|
||||
#define MUST_OR_THROW_INTERNAL_ERROR(...) \
|
||||
({ \
|
||||
/* Ignore -Wshadow to allow nesting the macro. */ \
|
||||
AK_IGNORE_DIAGNOSTIC("-Wshadow", \
|
||||
auto&& _temporary_result = (__VA_ARGS__)); \
|
||||
if (_temporary_result.is_error()) { \
|
||||
auto _completion = _temporary_result.release_error(); \
|
||||
\
|
||||
VERIFY(_completion.value().has_value()); \
|
||||
VERIFY(_completion.value()->is_object()); \
|
||||
VERIFY(::AK::is<JS::InternalError>(_completion.value()->as_object())); \
|
||||
\
|
||||
return _completion; \
|
||||
} \
|
||||
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
|
||||
"Do not return a reference from a fallible expression"); \
|
||||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
||||
// 6.2.3 The Completion Record Specification Type, https://tc39.es/ecma262/#sec-completion-record-specification-type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue