Project

General

Profile

Actions

Defect #30457

closed

MailHandler.safe_receive does not output any error log

Defect #30457: MailHandler.safe_receive does not output any error log

Added by Go MAEDA almost 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Email receiving
Target version:
Resolution:
Fixed
Affected version:

Description

MailHandler.safe_receive has a rescue clause that seems to be intended to catch all exceptions and log it.

  def self.safe_receive(*args)
    receive(*args)
  rescue Exception => e
    logger.error "MailHandler: an unexpected error occurred when receiving email: #{e.message}" if logger
    return false
  end

However, the expression "logger.error" does not log any events because the variable logger is undefined. Although there is a method definition for "logger" at source:tags/4.0.0/app/models/mail_handler.rb#L77, you cannot call the method from MailHandler.safe_receive because MailHandler.safe_receive is a class method and MailHandler#logger is an instance method.

As a result, the expression logger.error in MailHandler#safe_receive never logs errors because the expression itself causes NameError. To avoid this, logger should be replaced with Rails.logger. The attached patch fixes this issue.


Files


Related issues 2 (0 open — 2 closed)

Related to Redmine - Patch #11497: Dry up logging in MailHandler classClosedActions
Has duplicate Redmine - Defect #28874: MailHandler does not log exceptions caughtClosedActions

Updated by Go MAEDA almost 8 years ago Actions #1

  • Target version set to 4.1.0

Setting the target version to 4.1.0.

Updated by Go MAEDA almost 8 years ago Actions #2

  • Has duplicate Defect #28874: MailHandler does not log exceptions caught added

Updated by Go MAEDA almost 8 years ago Actions #3

  • Related to Patch #11497: Dry up logging in MailHandler class added

Updated by Go MAEDA over 7 years ago Actions #4

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.0 to 3.4.11
  • Resolution set to Fixed

Committed the fix.

Updated by Go MAEDA over 7 years ago Actions #5

  • Status changed from Resolved to Closed
Actions

Also available in: PDF Atom