lib/client.rb in navi_client-1.3.9 vs lib/client.rb in navi_client-1.3.10
- old
+ new
@@ -31,11 +31,11 @@
#
# imap_connection
#
# connect the app with imap server
#
- def imap_connection(server, username, password)
+ def imap_connection(server, username, password, exitOnFail = true)
# connect to IMAP server
imap = Net::IMAP.new server, ssl: true, certs: nil, verify: false
Net::IMAP.debug = @net_imap_debug
@@ -46,11 +46,11 @@
if @client_type == 'local'
unless capabilities.include? "IDLE" || @debug
@logger.info "'IDLE' IMAP capability not available in server: #{server}"
imap.disconnect
- exit
+ exit if exitOnFail
end
end
begin
# login
@@ -58,10 +58,12 @@
rescue Net::IMAP::NoResponseError => e
# mostly due to credentials error
@errors = {exception: e}
rescue Net::IMAP::BadResponseError => e
@errors = {exception: e}
+ rescue
+ @errors = {exception: e}
end
# return IMAP connection handler
imap
end
@@ -111,9 +113,11 @@
# mark as read
if @mark_as_read
imap.store(message_id, "+FLAGS", [:Seen])
end
end
+ rescue Errno::ECONNREFUSED => e
+ raise e
rescue => e
unless logger.nil?
logger.info "Issue processing email for uuid ##{message_id}, #{e.message}"
end