Module: JSONAPI::ActsAsResourceController::ClassMethods
- Defined in:
- lib/jsonapi/acts_as_resource_controller.rb
Overview
Pass in a methods or a block to be run when an exception is caught that is not a JSONAPI::Exceptions::Error Useful for additional logging or notification configuration that would normally depend on rails catching and rendering an exception. Ignores whitelist exceptions from config
Instance Method Summary collapse
Instance Method Details
#on_server_error(*args, &callback_block) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/jsonapi/acts_as_resource_controller.rb', line 197 def on_server_error(*args, &callback_block) callbacks = [] if callback_block callbacks << callback_block end method_callbacks = args.map do |method| ->(error) do if self.respond_to? method send(method, error) else Rails.logger.warn("#{method} not defined on #{self}, skipping error callback") end end end.compact callbacks += method_callbacks append_before_action { add_error_callbacks(callbacks) } end |