Module: Cms::ErrorHandling

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

Instance Method Summary collapse

Instance Method Details

#handle_access_denied(exception) ⇒ Object



30
31
32
33
34
# File 'app/controllers/cms/error_handling.rb', line 30

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

#handle_server_error(exception) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'app/controllers/cms/error_handling.rb', line 20

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

#with_format(format, &block) ⇒ Object

Ensures the entire render stack applies a specific format For example, this allows missing jpg’s to throw the proper error as opposed to 500



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

def with_format(format, &block)
  old_formats = self.formats
  self.formats = [format]
  result = block.call
  self.formats = old_formats
  result
end