Actions
Defect #30457
closedMailHandler.safe_receive does not output any error log
Start date:
Due date:
% Done:
0%
Estimated time:
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
Actions