mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Require error message for Response::network_error()
There will be a lot of different cases where we'll return an error response, and having a customized Promise rejection message seems quite useful. Note that this has to be distinct from the existing 'status message', which is required to be empty in those cases.
This commit is contained in:
parent
d8ebdef010
commit
32e0f0aec8
Notes:
sideshowbarker
2024-07-17 07:19:27 +09:00
Author: https://github.com/linusg
Commit: 32e0f0aec8
Pull-request: https://github.com/SerenityOS/serenity/pull/15795
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/davidot ✅
3 changed files with 12 additions and 6 deletions
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> create(JS::VM&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> aborted_network_error(JS::VM&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&, String message);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> appropriate_network_error(JS::VM&, FetchParams const&);
|
||||
|
||||
virtual ~Response() = default;
|
||||
|
@ -107,6 +107,9 @@ public:
|
|||
|
||||
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone(JS::VM&) const;
|
||||
|
||||
// Non-standard
|
||||
Optional<String> const& network_error_message() const { return m_network_error_message; }
|
||||
|
||||
protected:
|
||||
explicit Response(JS::NonnullGCPtr<HeaderList>);
|
||||
|
||||
|
@ -171,6 +174,9 @@ private:
|
|||
// https://fetch.spec.whatwg.org/#response-has-cross-origin-redirects
|
||||
// A response has an associated has-cross-origin-redirects (a boolean), which is initially false.
|
||||
bool m_has_cross_origin_redirects { false };
|
||||
|
||||
// Non-standard
|
||||
Optional<String> m_network_error_message;
|
||||
};
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-filtered-response
|
||||
|
@ -291,5 +297,4 @@ private:
|
|||
JS::NonnullGCPtr<HeaderList> m_header_list;
|
||||
Optional<Body> m_body;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue