Skip to content

Instantly share code, notes, and snippets.

@BlakeWilliams
Created April 13, 2021 17:47
Show Gist options
  • Save BlakeWilliams/f17bd24ac9234638c03ac39dde6e9271 to your computer and use it in GitHub Desktop.
Save BlakeWilliams/f17bd24ac9234638c03ac39dde6e9271 to your computer and use it in GitHub Desktop.
module Rescuable
extend ActiveSupport::Concern
class_methods do
def rescue_with_empty_content?
defined?(@rescue_with_empty_content) && @rescue_with_empty_content
end
def rescue_with_empty_content!
@rescue_with_empty_content = true
end
end
def render_in(*)
super
rescue StandardError => e
raise unless self.class.rescue_with_empty_content?
raise unless Rails.env.production?
respond_to?(:on_error, true) && on_error(e)
""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment