mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 02:26:10 +00:00
LibIMAP: Reject a promise when a command couldn't be sent
I feel like ErrorOr<RefPtr<Promise<>>> was an overkill. Promises already hold an optional error type we can use instead.
This commit is contained in:
parent
51fefb57fc
commit
44ea5092e8
Notes:
sideshowbarker
2024-07-18 02:47:59 +09:00
Author: https://github.com/krkk
Commit: 44ea5092e8
Pull-request: https://github.com/SerenityOS/serenity/pull/20833
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 5 additions and 2 deletions
|
@ -179,8 +179,11 @@ ErrorOr<RefPtr<Promise<Optional<Response>>>> Client::send_command(Command&& comm
|
|||
auto promise = Promise<Optional<Response>>::construct();
|
||||
m_pending_promises.append(promise);
|
||||
|
||||
if (m_pending_promises.size() == 1)
|
||||
TRY(send_next_command());
|
||||
if (m_pending_promises.size() == 1) {
|
||||
auto maybe_error = send_next_command();
|
||||
if (maybe_error.is_error())
|
||||
promise->reject(maybe_error.release_error());
|
||||
}
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue