mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 18:15:09 +00:00
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.
This commit is contained in:
parent
c5eeb303d8
commit
f320406a4c
2 changed files with 4 additions and 5 deletions
|
@ -56,6 +56,8 @@ struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<void>> {
|
|||
using Type = JS::Value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&& exception)
|
||||
{
|
||||
return exception.visit(
|
||||
|
@ -81,8 +83,6 @@ ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&
|
|||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
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();
|
||||
|
||||
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(); })
|
||||
return result.value();
|
||||
|
|
|
@ -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.
|
||||
auto exception_or_request_object = Request::construct_impl(realm, input, init);
|
||||
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());
|
||||
return verify_cast<JS::Promise>(*promise_capability->promise().ptr());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue