Rick DeNatale
2007-Nov-14 21:39 UTC
Exception Notification plugin options hash handling????? backwards merge?
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 rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---
Rick DeNatale
2007-Nov-14 21:58 UTC
Re: Exception Notification plugin options hash handling????? backwards merge?
On Nov 14, 2007 4:39 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:> 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?For what it''s worth, I switched this locally to body { :controller => controller, :request => request, :exception => exception, :host => request.env["HTTP_HOST"], :backtrace => sanitize_backtrace(exception.backtrace), :rails_root => rails_root, :data => data, :sections => sections }.merge(data) And $ rake test:plugins PLUGIN=exception_notification runs with no failures/errors! -- 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Rick DeNatale
2007-Nov-14 22:12 UTC
Re: Exception Notification plugin options hash handling????? backwards merge?
What the heck! http://dev.rubyonrails.org/ticket/10168 -- 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---