module Ketchup::Exception::Controller
Public Instance Methods
ketchup() { || ... }
click to toggle source
INTERNAL - The method which is called by around_filter
Finds the error configuration:
:error - Class of the Error :with - Proc or method name to call. If this is ommited be sure to implement an respond_with_error(err) method. :remember - Boolean. If true error will be saved in database Default true :notify - Boolean. Default true It sends an email to any reciepient which is defined during Ketchup configuration. If deliver_mail in Ketchup configuration is set to false, sending mail is ignored :log - Boolean. Default true Call the proc that is defined in log_error
# File lib/rails/controller.rb, line 75 def ketchup(&block) yield rescue => err if Ketchup::Exception.environment.include?(Rails.env.to_sym) # Default error configuration default_conf = { :with => :respond_with_error, :remember => true, :notify => true, :log => true } # Find specific error configuration conf = self.class.rescue_errors.find { |error_conf| error_conf[:error] == err.class } conf = default_conf.merge(conf || {}) # save to database if Ketchup::Exception.persist Ketchup::Handler.action(:database, :exception => err) if conf[:remember] end # send an email if Ketchup::Exception.deliver_mail Ketchup::Handler.action(:mail, {:exception => err, :host => request.host_with_port}) if conf[:notify] end # log error if conf[:log] Ketchup::Exception.log_error.call(err) end # Run error handler if conf[:with].is_a? Proc conf[:with].call(err) else self.send(conf[:with], err) end else raise err end end