Skip to content

Instantly share code, notes, and snippets.

@thomasritz
Created May 10, 2012 14:23
Show Gist options
  • Save thomasritz/2653322 to your computer and use it in GitHub Desktop.
Save thomasritz/2653322 to your computer and use it in GitHub Desktop.
If rendering a Cell causes an error, catch it, report the exception to Airbrake and render nothing
# config/application.rb
unless Rails.env.development?
Cell::Rendering::ClassMethods.class_eval do
def render_cell_for(name, state, *args)
cell = nil
cell = create_cell_for(name, *args)
yield cell if block_given?
render_cell_state(cell, state, *args)
rescue => exception
if cell
parent = cell.parent_controller
until parent.is_a?(ActionController::Base)
parent = parent.parent_controller
end
parent.send(:notify_airbrake, exception)
else
Airbrake.notify(exception)
end
""
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment