diff --git a/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h b/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h index 2fa51c1f11..c023c362d6 100644 --- a/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h +++ b/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h @@ -20,6 +20,12 @@ constexpr bool IsExceptionOr = false; template constexpr bool IsExceptionOr> = true; +template +constexpr bool IsThrowCompletionOr = false; + +template +constexpr bool IsThrowCompletionOr> = true; + namespace Detail { template @@ -32,6 +38,11 @@ struct ExtractExceptionOrValueType> { using Type = T; }; +template +struct ExtractExceptionOrValueType> { + using Type = T; +}; + template<> struct ExtractExceptionOrValueType { using Type = JS::Value; @@ -79,7 +90,7 @@ using ExtractExceptionOrValueType = typename Detail::ExtractExceptionOrValueType // void or ExceptionOr: JS::ThrowCompletionOr, always returns JS::js_undefined() // ExceptionOr: JS::ThrowCompletionOr // T: JS::ThrowCompletionOr -template()()), typename Ret = Conditional && !IsVoid, T, ExtractExceptionOrValueType>> +template()()), typename Ret = Conditional && !IsVoid && !IsThrowCompletionOr, T, ExtractExceptionOrValueType>> JS::ThrowCompletionOr throw_dom_exception_if_needed(auto&& global_object, F&& fn) { if constexpr (IsExceptionOr) {