Module: Cms::ContentRenderingSupport

Included in:
ContentController
Defined in:
lib/cms/content_rendering_support.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/cms/content_rendering_support.rb', line 7

def self.included(base)
  base.send :include, Cms::ErrorHandling

  base.rescue_from Exception, :with => :handle_server_error_on_page
  base.rescue_from Cms::Errors::AccessDenied, :with => :handle_access_denied_on_page
  base.rescue_from ActiveRecord::RecordNotFound, :with => :handle_not_found_on_page
end

Instance Method Details

#handle_access_denied_on_page(exception) ⇒ Object



20
21
22
23
# File 'lib/cms/content_rendering_support.rb', line 20

def handle_access_denied_on_page(exception)
  logger.warn "Access Denied"
  handle_error_with_cms_page('/system/access_denied', exception, :forbidden)
end

#handle_not_found_on_page(exception) ⇒ Object



15
16
17
18
# File 'lib/cms/content_rendering_support.rb', line 15

def handle_not_found_on_page(exception)
  logger.warn "Page Not Found"
  handle_error_with_cms_page('/system/not_found', exception, :not_found)
end

#handle_server_error_on_page(exception) ⇒ Object



25
26
27
28
29
# File 'lib/cms/content_rendering_support.rb', line 25

def handle_server_error_on_page(exception)
  logger.warn "Exception: #{exception.message}\n"
  logger.warn "#{exception.backtrace.join("\n")}\n"
  handle_error_with_cms_page('/system/server_error', exception, :internal_server_error)
end