Permalink
Browse files

safely handle render exception

closes #112
  • Loading branch information...
shime committed Aug 24, 2012
1 parent c926886 commit 393b19a451aa35d378194287ea3ad7a5d0447eee
Showing with 11 additions and 6 deletions.
  1. +11 −6 lib/airbrake/rails/middleware/exceptions_catcher.rb
@@ -1,3 +1,4 @@
+class AirbrakeError < StandardError; end
module Airbrake
module Rails
module Middleware
@@ -14,12 +15,16 @@ def skip_user_agent?(env)
end
def render_exception_with_airbrake(env,exception)
- controller = env['action_controller.instance']
- env['airbrake.error_id'] = Airbrake.
- notify_or_ignore(exception,
- controller.try(:airbrake_request_data) || {:rack_env => env}) unless skip_user_agent?(env)
- if defined?(controller.rescue_action_in_public_without_airbrake)
- controller.rescue_action_in_public_without_airbrake(exception)
+ begin
+ controller = env['action_controller.instance']
+ env['airbrake.error_id'] = Airbrake.
+ notify_or_ignore(exception,
+ controller.try(:airbrake_request_data) || {:rack_env => env}) unless skip_user_agent?(env)
+ if defined?(controller.rescue_action_in_public_without_airbrake)
+ controller.rescue_action_in_public_without_airbrake(exception)
+ end
+ rescue
+ # do nothing
end
render_exception_without_airbrake(env,exception)
end

0 comments on commit 393b19a

Please sign in to comment.