1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:07:34 +00:00

LibWeb: Add WebIDL::ExceptionOr constructor for wrapped ValueType

This is copied from JS::ThrowCompletionOr and will allow using them
interchangeably with types wrapped by JS::Value such as JS::Object*.
This commit is contained in:
Linus Groh 2022-09-25 19:11:43 +01:00
parent 4461234898
commit 426e32e5c0

View file

@ -50,6 +50,15 @@ public:
{
}
// Allows implicit construction of ExceptionOr<T> from a type U if T(U) is a supported constructor.
// Most commonly: Value from Object* or similar, so we can omit the curly braces from "return { TRY(...) };".
// Disabled for POD types to avoid weird conversion shenanigans.
template<typename WrappedValueType>
ExceptionOr(WrappedValueType result) requires(!IsPOD<ValueType>)
: m_result(move(result))
{
}
ExceptionOr(JS::NonnullGCPtr<DOMException> exception)
: m_exception(move(exception))
{