Sha256: 3f12ea2165c5d2aec1c0bf9fe3c6bc91201e0dfac12b651dffb7d3bbde2e774d
Contents?: true
Size: 1.58 KB
Versions: 34
Compression:
Stored size: 1.58 KB
Contents
module Workarea module Storefront class ErrorsController < Storefront::ApplicationController def not_found redirect_url = Navigation::Redirect.find_destination( request.env['action_dispatch.original_path'] ) if redirect_url.present? redirect_to redirect_url, status: :moved_permanently else render_error_page(404) end end def internal # This ensures any exception handling (e.g. Airbrake or Sentry) will see # the error in their middleware, and then report on it. request.env['rack.exception'] = request.env['action_dispatch.exception'] render_error_page(500) end def offline content = Content.for('offline') @content = ContentViewModel.wrap(content) render('workarea/storefront/errors/show') end private def render_error_page(error_status) name = Rack::Utils::HTTP_STATUS_CODES[error_status].titleize respond_to do |format| format.all do if !request.format.html? head error_status elsif content = Content.for(name) @content = ContentViewModel.new(content) render( template: 'workarea/storefront/errors/show', status: error_status ) else render( file: "#{Rails.root}/public/#{error_status}.html", layout: nil, status: error_status ) end end end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems