diff options
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h | 13 |
1 files changed, 12 insertions, 1 deletions
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<typename T> constexpr bool IsExceptionOr<DOM::ExceptionOr<T>> = true; +template<typename> +constexpr bool IsThrowCompletionOr = false; + +template<typename T> +constexpr bool IsThrowCompletionOr<JS::ThrowCompletionOr<T>> = true; + namespace Detail { template<typename T> @@ -32,6 +38,11 @@ struct ExtractExceptionOrValueType<DOM::ExceptionOr<T>> { using Type = T; }; +template<typename T> +struct ExtractExceptionOrValueType<JS::ThrowCompletionOr<T>> { + using Type = T; +}; + template<> struct ExtractExceptionOrValueType<void> { using Type = JS::Value; @@ -79,7 +90,7 @@ using ExtractExceptionOrValueType = typename Detail::ExtractExceptionOrValueType // void or ExceptionOr<void>: JS::ThrowCompletionOr<JS::Value>, always returns JS::js_undefined() // ExceptionOr<T>: JS::ThrowCompletionOr<T> // T: JS::ThrowCompletionOr<T> -template<typename F, typename T = decltype(declval<F>()()), typename Ret = Conditional<!IsExceptionOr<T> && !IsVoid<T>, T, ExtractExceptionOrValueType<T>>> +template<typename F, typename T = decltype(declval<F>()()), typename Ret = Conditional<!IsExceptionOr<T> && !IsVoid<T> && !IsThrowCompletionOr<T>, T, ExtractExceptionOrValueType<T>>> JS::ThrowCompletionOr<Ret> throw_dom_exception_if_needed(auto&& global_object, F&& fn) { if constexpr (IsExceptionOr<T>) { |