1
Fork 0
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:
Karol Kosek 2023-08-29 16:47:01 +02:00 committed by Andrew Kaster
parent 51fefb57fc
commit 44ea5092e8

View file

@ -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;
}