2

How can I access ExceptionNotifier variables such as sender_address or exception_recipients in my custom mailer class? Since ExceptionNotifier is implemented as Rack middleware, I'm not sure how to go about it.

Alex Korban
  • 14,916
  • 5
  • 44
  • 55
  • Please explain what you want to do in practice. There are several alternatives, depending on what you want to accomplish. – Simone Carletti May 12 '11 at 08:59
  • @Simone: I'd like to send exception notifications when an exception happens in a delayed_job worker. In order to do that, it looks like I have to write my own mailer, so I'd like to get `sender_address` and `exception_recipients` from the ExceptionNotifier configuration. – Alex Korban May 12 '11 at 09:21

1 Answers1

1

I still don't know how to access the ExceptionNotifier variables, so the workaround I decided on is to add these variables to Rails config instead, and use them to configure both ExceptionNotifier and my custom mailer:

config.exception_subject_prefix = "[App Error] "
config.exception_sender = "support@example.com"
config.exception_recipients = %w{support@example.com}

config.middleware.use "::ExceptionNotifier",
                      :email_prefix => config.exception_subject_prefix,
                      :sender_address => %{ #{config.exception_sender} },
                      :exception_recipients => config.exception_recipients

The config variables can be accessed elsewhere as Rails.configuration.exception_sender and so on.

Alex Korban
  • 14,916
  • 5
  • 44
  • 55