LibWeb: Properly implement IDBRequest::error()
This commit is contained in:
parent
29ddaa76e7
commit
204d776cdb
Notes:
github-actions[bot]
2024-11-26 13:52:26 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/204d776cdb3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2236 Reviewed-by: https://github.com/gmta ✅
2 changed files with 12 additions and 1 deletions
|
@ -65,4 +65,15 @@ WebIDL::CallbackType* IDBRequest::onerror()
|
|||
return m_done ? Bindings::IDBRequestReadyState::Done : Bindings::IDBRequestReadyState::Pending;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dom-idbrequest-error
|
||||
[[nodiscard]] WebIDL::ExceptionOr<GC::Ptr<WebIDL::DOMException>> IDBRequest::error() const
|
||||
{
|
||||
// 1. If this's done flag is false, then throw an "InvalidStateError" DOMException.
|
||||
if (!m_done)
|
||||
return WebIDL::InvalidStateError::create(realm(), "The request is not done"_string);
|
||||
|
||||
// 2. Otherwise, return this's error, or null if no error occurred.
|
||||
return m_error;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ public:
|
|||
virtual ~IDBRequest() override;
|
||||
|
||||
[[nodiscard]] JS::Value result() const { return m_result; }
|
||||
[[nodiscard]] GC::Ptr<WebIDL::DOMException> error() const { return m_error; }
|
||||
[[nodiscard]] bool done() const { return m_done; }
|
||||
[[nodiscard]] bool processed() const { return m_processed; }
|
||||
[[nodiscard]] IDBRequestSource source() const { return m_source; }
|
||||
|
||||
[[nodiscard]] Bindings::IDBRequestReadyState ready_state() const;
|
||||
[[nodiscard]] WebIDL::ExceptionOr<GC::Ptr<WebIDL::DOMException>> error() const;
|
||||
|
||||
void set_done(bool done) { m_done = done; }
|
||||
void set_result(JS::Value result) { m_result = result; }
|
||||
|
|
Loading…
Add table
Reference in a new issue