Send personally caught exceptions?
How do I send off errors that I personally caught? I was told the following would work in the latest rails (3.0.7 I believe) I'm using the hoptoad_notifier gem
class HomeController < ApplicationController
def index
begin
raise 'test begin-rescue-end'
rescue
hoptoad_notify $!
end
end end
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Matt Jankowski on 01 May, 2011 03:02 PM
Yes, that's correct for controllers when hoptoad_notify method is available. You can read more in the notifier plugin README - https://github.com/thoughtbot/hoptoad_notifier/blob/master/README.md
Matt Jankowski closed this discussion on 01 May, 2011 03:02 PM.
Mohammad El-Abid re-opened this discussion on 01 May, 2011 03:04 PM
3 Posted by Mohammad El-Abid on 01 May, 2011 03:04 PM
I tried that but it gave an error of undefined method. I'll recreate it in a few hours and post back.
Sent from my iPod Touch 4G
4 Posted by Mohammad on 01 May, 2011 03:28 PM
NoMethodError (undefined method
hoptoad_notify' for #<HomeController:0x5505678> ): app/controllers/home_controller.rb:6:inrescue in index' app/controllers/home_controller.rb:3:in `index'Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatc
h/middleware/templates/rescues/trace.erb (1.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatc
h/middleware/templates/rescues/request_and_response.erb (72.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatc
h/middleware/templates/rescues/diagnostics.erb within rescues/layout (119.5ms)
5 Posted by Harold Gimenez on 02 May, 2011 12:57 AM
Hi Mohammad,
The method is actually called
notify_hoptoad. Can you give it a shot?And just as an aside, I think it's clearer to grab the exception object in the
rescuecall and send it over to Hoptoad, instead of using$!. So even though both should work, try this:Let us know how that goes.
6 Posted by Mohammad El-Abid on 03 May, 2011 09:07 PM
Thank you Harold, that's what was wrong! It's working fine now.
7 Posted by Harold Gimenez on 03 May, 2011 09:10 PM
Glad it's working for you, and thanks for using Hoptoad!
Harold Gimenez closed this discussion on 03 May, 2011 09:10 PM.