fix: distinguish imap auth failures from transient errors with exponential backoff

This commit is contained in:
Tanmay Deep Sharma
2026-02-24 19:52:37 +05:30
parent 2a31ec7afd
commit 2963ccbd47
4 changed files with 19 additions and 7 deletions
+9 -1
View File
@@ -1,5 +1,7 @@
require 'net/imap'
class Imap::AuthenticationError < StandardError; end
module ExceptionList
REST_CLIENT_EXCEPTIONS = [RestClient::NotFound, RestClient::GatewayTimeout, RestClient::BadRequest,
RestClient::MethodNotAllowed, RestClient::Forbidden, RestClient::InternalServerError,
@@ -14,6 +16,12 @@ module ExceptionList
IMAP_EXCEPTIONS = [
Errno::ECONNREFUSED, Net::OpenTimeout,
Errno::ECONNRESET, Errno::ENETUNREACH, Net::IMAP::ByeResponseError,
Net::IMAP::NoResponseError, SocketError
SocketError
].freeze
IMAP_TRANSIENT_EXCEPTIONS = (IMAP_EXCEPTIONS + [
EOFError, OpenSSL::SSL::SSLError, Net::IMAP::NoResponseError, Net::IMAP::BadResponseError,
Net::IMAP::InvalidResponseError, Net::IMAP::ResponseParseError,
Net::IMAP::ResponseReadError, Net::IMAP::ResponseTooLargeError
]).freeze
end