Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document action mailer rescue_from [ci-skip] #44777

Merged
merged 1 commit into from May 3, 2022

Conversation

jean-francois-labbe
Copy link
Contributor

@jean-francois-labbe jean-francois-labbe commented Mar 28, 2022

Summary

The ActionMailer::Base documentation does not mention the rescue_from nor the fact that using rescue inside a mailer action will not work for exceptions raised inside the mail method.

I faced an issue when working on a mailer that looked like this:

class NotifyMailer < ApplicationMailer
  def notify
    ...
    mail(to: recipient)
  rescue Postmark::InactiveRecipientError => e
     Rails.logger.warn e.message
  end
end

The rescue block was never executed even though the bug tracker was full of Postmark::InactiveRecipientError coming from this mailer action.

So I'd like to document how to use rescue_from inside a mailer.

actionmailer/lib/action_mailer/base.rb Outdated Show resolved Hide resolved
actionmailer/lib/action_mailer/base.rb Outdated Show resolved Hide resolved
actionmailer/lib/action_mailer/base.rb Outdated Show resolved Hide resolved
actionmailer/lib/action_mailer/base.rb Outdated Show resolved Hide resolved
@jean-francois-labbe
Copy link
Contributor Author

@jean-francois-labbe jean-francois-labbe commented May 2, 2022

@jonathanhefner I accepted your suggestions. Thanks for helping me with this.

@jonathanhefner
Copy link
Member

@jonathanhefner jonathanhefner commented May 2, 2022

@jean-francois-labbe Looks good! Would you mind squashing the commits? Then I'll give this a merge!

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
@jean-francois-labbe
Copy link
Contributor Author

@jean-francois-labbe jean-francois-labbe commented May 3, 2022

@jonathanhefner commits squashed. It's ready.

@jonathanhefner jonathanhefner merged commit e4ec2cb into rails:main May 3, 2022
3 checks passed
@jonathanhefner
Copy link
Member

@jonathanhefner jonathanhefner commented May 3, 2022

Thank you, @jean-francois-labbe! 😄

Backported to 7-0-stable in ae98f49.

jonathanhefner added a commit that referenced this issue May 3, 2022
Document action mailer rescue_from [ci-skip]

(cherry picked from commit e4ec2cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants