Today I worked on adding email exception notification to some
ancillary background processes for a Rails app.

Since I was already using Jamis' exception notification plugin to
notify me of errors in controllers for the web app, I figured that the
path of least resistance was to try to figure out how to hook it into
the daemon code.

At first it looked easy. I just needed to 'mock' some methods so that
I could mimic the controller, and (as it turned out the request since
there wasn't one).  it looked like I could set the sections list and
the host by calling:

      ExceptionNotifier.deliver_exception_notification(
        exception,
        self,   # Controller
        nil,   # Request
        :host => "localhost", :sections => %w(environment backtrace)
      )

  Thinking that the code in ExceptionNotifier#exception_notification
would prefer the values in the options hash parameter over what was
pre-coded.

  But this didn't work and looking at the method in question:

  def exception_notification(exception, controller, request, data={})
    subject    
"#{email_prefix}#{controller.controller_name}##{controller.action_name}
(#{exception.class}) #{exception.message.inspect}"

    recipients exception_recipients
    from       sender_address

    body       data.merge({ :controller => controller, :request => request,
                  :exception => exception, :host => request.env["HTTP_HOST"],
                  :backtrace => sanitize_backtrace(exception.backtrace),
                  :rails_root => rails_root, :data => data,
                  :sections => sections })
  end

It appears to me that he receiver and parameter of that merge message
in the argument to the body message should be reversed.

Am I missing something here?

Because of this I had to do some fairly ugly code which temporarily
set the sections cattr, and I had to act like the request insofar as
providing an env method which returned a hash mapping "HTTP_HOST" to
"localhost"

If this is a bug rather than something I've overlooked, should I
submit a patch to the rails trac or is there somewhere else?
-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to