Procházet zdrojové kódy

LibWeb: Make Bindings::dom_exception_to_throw_completion public API

I found myself needing to call this method when attempting to implement
Blob::text and Blob::array_buffer. Turns out that the only caller
outside of the Detail namespace  already had a FIXME to make this a
public API - so let's do that.
Shannon Booth před 2 roky
rodič
revize
f320406a4c

+ 3 - 3
Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h

@@ -56,6 +56,8 @@ struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<void>> {
     using Type = JS::Value;
     using Type = JS::Value;
 };
 };
 
 
+}
+
 ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&& exception)
 ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&& exception)
 {
 {
     return exception.visit(
     return exception.visit(
@@ -81,8 +83,6 @@ ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&
         });
         });
 }
 }
 
 
-}
-
 template<typename T>
 template<typename T>
 using ExtractExceptionOrValueType = typename Detail::ExtractExceptionOrValueType<T>::Type;
 using ExtractExceptionOrValueType = typename Detail::ExtractExceptionOrValueType<T>::Type;
 
 
@@ -97,7 +97,7 @@ JS::ThrowCompletionOr<Ret> throw_dom_exception_if_needed(JS::VM& vm, F&& fn)
         auto&& result = fn();
         auto&& result = fn();
 
 
         if (result.is_exception())
         if (result.is_exception())
-            return Detail::dom_exception_to_throw_completion(vm, result.exception());
+            return dom_exception_to_throw_completion(vm, result.exception());
 
 
         if constexpr (requires(T v) { v.value(); })
         if constexpr (requires(T v) { v.value(); })
             return result.value();
             return result.value();

+ 1 - 2
Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp

@@ -36,8 +36,7 @@ JS::NonnullGCPtr<JS::Promise> fetch(JS::VM& vm, RequestInfo const& input, Reques
     //    as arguments. If this throws an exception, reject p with it and return p.
     //    as arguments. If this throws an exception, reject p with it and return p.
     auto exception_or_request_object = Request::construct_impl(realm, input, init);
     auto exception_or_request_object = Request::construct_impl(realm, input, init);
     if (exception_or_request_object.is_exception()) {
     if (exception_or_request_object.is_exception()) {
-        // FIXME: We should probably make this a public API?
-        auto throw_completion = Bindings::Detail::dom_exception_to_throw_completion(vm, exception_or_request_object.release_error());
+        auto throw_completion = Bindings::dom_exception_to_throw_completion(vm, exception_or_request_object.exception());
         WebIDL::reject_promise(realm, promise_capability, *throw_completion.value());
         WebIDL::reject_promise(realm, promise_capability, *throw_completion.value());
         return verify_cast<JS::Promise>(*promise_capability->promise().ptr());
         return verify_cast<JS::Promise>(*promise_capability->promise().ptr());
     }
     }