From f81f3fb0608cbffe195b5ece85c824c13d995f7c Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Mon, 16 Dec 2019 15:07:46 +0300 Subject: [PATCH] Do not panic on failure to read IMAP server greeting --- src/imap_client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imap_client.rs b/src/imap_client.rs index 3f4da0de8..c0216fbd9 100644 --- a/src/imap_client.rs +++ b/src/imap_client.rs @@ -46,7 +46,7 @@ impl Client { let _greeting = client .read_response() .await - .expect("failed to read greeting"); + .ok_or_else(|| ImapError::Bad("failed to read greeting".to_string()))?; Ok(Client::Secure(client)) } @@ -61,7 +61,7 @@ impl Client { let _greeting = client .read_response() .await - .expect("failed to read greeting"); + .ok_or_else(|| ImapError::Bad("failed to read greeting".to_string()))?; Ok(Client::Insecure(client)) }