diff --git a/Userland/Libraries/LibWeb/DOM/ExceptionOr.h b/Userland/Libraries/LibWeb/DOM/ExceptionOr.h index ec889a3337..e741cbceba 100644 --- a/Userland/Libraries/LibWeb/DOM/ExceptionOr.h +++ b/Userland/Libraries/LibWeb/DOM/ExceptionOr.h @@ -34,7 +34,10 @@ struct SimpleException { template class ExceptionOr { public: - ExceptionOr() requires(IsSame) = default; + ExceptionOr() requires(IsSame) + : m_result(Empty {}) + { + } ExceptionOr(const ValueType& result) : m_result(result) @@ -70,7 +73,7 @@ public: return m_result.value(); } - ValueType release_value() requires(!IsSame) + ValueType release_value() { return m_result.release_value(); } @@ -85,6 +88,10 @@ public: return !m_exception.template has(); } + // These are for compatibility with the TRY() macro in AK. + [[nodiscard]] bool is_error() const { return is_exception(); } + Variant> release_error() { return exception(); } + private: Optional m_result; // https://webidl.spec.whatwg.org/#idl-exceptions