lib/client.rb in navi_client-1.3.7 vs lib/client.rb in navi_client-1.3.8

- old
+ new

@@ -94,23 +94,27 @@ @logger.info "Downloading #{message_ids.count} emails." end end message_ids.each_with_index do |message_id, i| - # fetch all the email contents - data = imap.uid_fetch(message_id, "RFC822") - data.each do |d| - msg = d.attr['RFC822'] - # instantiate a Mail object to avoid further IMAP parameters nightmares - mail = Mail.read_from_string msg + begin + # fetch all the email contents + data = imap.uid_fetch(message_id, "RFC822") + data.each do |d| + msg = d.attr['RFC822'] + # instantiate a Mail object to avoid further IMAP parameters nightmares + mail = Mail.read_from_string msg - # call the block with mail object as param - process_email_block.call mail, i, i == message_ids.length-1, message_id + # call the block with mail object as param + process_email_block.call mail, i, i == message_ids.length-1, message_id - # mark as read - if @mark_as_read - imap.store(message_id, "+FLAGS", [:Seen]) + # mark as read + if @mark_as_read + imap.store(message_id, "+FLAGS", [:Seen]) + end end + rescue => e + logger.info "Issue processing email for uuid ##{message_id}, #{e.message}" end end end