Module: Cms::ErrorHandling

Included in:
ApplicationController
Defined in:
app/controllers/cms/error_handling.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(controller) ⇒ Object



3
4
5
6
7
8
# File 'app/controllers/cms/error_handling.rb', line 3

def self.included(controller)
  controller.class_eval do
    rescue_from Exception, :with => :handle_server_error unless RAILS_ENV == "test"
    rescue_from Cms::Errors::AccessDenied, :with => :handle_access_denied
  end
end

Instance Method Details

#handle_access_denied(exception) ⇒ Object



18
19
20
21
22
# File 'app/controllers/cms/error_handling.rb', line 18

def handle_access_denied(exception)
  render :layout   => 'cms/application', 
         :template => 'cms/shared/access_denied',
         :status => 403
end

#handle_server_error(exception) ⇒ Object



10
11
12
13
14
15
16
# File 'app/controllers/cms/error_handling.rb', line 10

def handle_server_error(exception)
  logger.error "Handling Exception: #{exception}"
  render :layout => 'cms/application', 
    :template => 'cms/shared/error', 
    :status => :internal_server_error,
    :locals => {:exception => exception}
end