module Ketchup::Exception::Controller::ClassMethods
Public Instance Methods
ketchup_exceptions(*args) { |self| ... }
click to toggle source
PUBLIC - class method to provide exception handling support.
It takes an optional configuration block:
Example:
class MainController < ApplicationController
ketchup_exceptions do c.resuce_errors = [ {:error => RestClient::ServerBrokeConnection, :with => :server_not_responding} ] c.before_respond = :log_error c.after_rescue = :respond_with_error end
It assigns all rescue_errors configurations to rescue_from and a controller extension method to around_filter.
# File lib/rails/controller.rb, line 52 def ketchup_exceptions(*args) yield(self) if block_given? around_filter :ketchup end
rescue_errors=(error_conf)
click to toggle source
INTERNAL - A setter to define errors which are treated in a special way.
error_conf - An Array consisting of Hashes with :error,:with keys.
error - The Expection to be rescued. with - A Symbol of method name which handles the rescue.
Example:
{:error => NoMethodError, :with => :catch_no_methods}
# File lib/rails/controller.rb, line 27 def rescue_errors=(error_conf) @@rescue_errors = [] if @@rescue_errors.nil? error_conf.each do |conf| @@rescue_errors << conf end end