mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibIMAP+Mail+test-imap: Make Client requests infailable
This commit is contained in:
parent
44ea5092e8
commit
55d730bd5c
4 changed files with 83 additions and 84 deletions
|
@ -137,7 +137,7 @@ ErrorOr<bool> MailWidget::connect_and_login()
|
|||
|
||||
m_statusbar->set_text(String::formatted("Connected. Logging in as {}...", username).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto response = TRY(TRY(m_imap_client->login(username, password))->await()).release_value();
|
||||
auto response = TRY(m_imap_client->login(username, password)->await()).release_value();
|
||||
|
||||
if (response.status() != IMAP::ResponseStatus::OK) {
|
||||
dbgln("Failed to login. The server says: '{}'", response.response_text());
|
||||
|
@ -147,7 +147,7 @@ ErrorOr<bool> MailWidget::connect_and_login()
|
|||
}
|
||||
|
||||
m_statusbar->set_text("Logged in. Loading mailboxes..."_string);
|
||||
response = TRY(TRY(m_imap_client->list(""sv, "*"sv))->await()).release_value();
|
||||
response = TRY(m_imap_client->list(""sv, "*"sv)->await()).release_value();
|
||||
|
||||
if (response.status() != IMAP::ResponseStatus::OK) {
|
||||
dbgln("Failed to retrieve mailboxes. The server says: '{}'", response.response_text());
|
||||
|
@ -174,7 +174,7 @@ void MailWidget::on_window_close()
|
|||
// User closed main window before a connection was established
|
||||
return;
|
||||
}
|
||||
auto response = move(MUST(MUST(m_imap_client->send_simple_command(IMAP::CommandType::Logout))->await()).release_value().get<IMAP::SolidResponse>());
|
||||
auto response = move(MUST(m_imap_client->send_simple_command(IMAP::CommandType::Logout)->await()).release_value().get<IMAP::SolidResponse>());
|
||||
VERIFY(response.status() == IMAP::ResponseStatus::OK);
|
||||
|
||||
m_imap_client->close();
|
||||
|
@ -265,7 +265,7 @@ void MailWidget::selected_mailbox()
|
|||
if (mailbox.flags & (unsigned)IMAP::MailboxFlag::NoSelect)
|
||||
return;
|
||||
|
||||
auto response = MUST(MUST(m_imap_client->select(mailbox.name))->await()).release_value();
|
||||
auto response = MUST(m_imap_client->select(mailbox.name)->await()).release_value();
|
||||
|
||||
if (response.status() != IMAP::ResponseStatus::OK) {
|
||||
dbgln("Failed to select mailbox. The server says: '{}'", response.response_text());
|
||||
|
@ -297,9 +297,8 @@ void MailWidget::selected_mailbox()
|
|||
},
|
||||
};
|
||||
|
||||
auto fetch_response = MUST(MUST(m_imap_client->fetch(fetch_command, false))->await()).release_value();
|
||||
|
||||
if (response.status() != IMAP::ResponseStatus::OK) {
|
||||
auto fetch_response = MUST(m_imap_client->fetch(fetch_command, false)->await()).release_value();
|
||||
if (fetch_response.status() != IMAP::ResponseStatus::OK) {
|
||||
dbgln("Failed to retrieve subject/from for e-mails. The server says: '{}'", response.response_text());
|
||||
m_statusbar->set_text(String::formatted("[{}]: Failed to fetch messages :^(", mailbox.name).release_value_but_fixme_should_propagate_errors());
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to retrieve e-mails. The server says: '{}'", response.response_text()));
|
||||
|
@ -453,7 +452,7 @@ void MailWidget::selected_email_to_load()
|
|||
},
|
||||
};
|
||||
|
||||
auto fetch_response = MUST(MUST(m_imap_client->fetch(fetch_command, false))->await()).release_value();
|
||||
auto fetch_response = MUST(m_imap_client->fetch(fetch_command, false)->await()).release_value();
|
||||
|
||||
if (fetch_response.status() != IMAP::ResponseStatus::OK) {
|
||||
dbgln("Failed to retrieve the body structure of the selected e-mail. The server says: '{}'", fetch_response.response_text());
|
||||
|
@ -517,7 +516,7 @@ void MailWidget::selected_email_to_load()
|
|||
},
|
||||
};
|
||||
|
||||
fetch_response = MUST(MUST(m_imap_client->fetch(fetch_command, false))->await()).release_value();
|
||||
fetch_response = MUST(m_imap_client->fetch(fetch_command, false)->await()).release_value();
|
||||
|
||||
if (fetch_response.status() != IMAP::ResponseStatus::OK) {
|
||||
dbgln("Failed to retrieve the body of the selected e-mail. The server says: '{}'", fetch_response.response_text());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue