Created
May 10, 2012 14:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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