mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +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
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