module JSONAPI::ActsAsResourceController::ClassMethods
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
Public Instance Methods
on_server_error(*args, &callback_block)
click to toggle source
# File lib/jsonapi/acts_as_resource_controller.rb, line 315 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 self.class_variable_set :@@server_error_callbacks, callbacks end