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

Version Path
workarea-storefront-3.4.45 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.44 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.43 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.42 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.41 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.40 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.39 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.38 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.37 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.36 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.35 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.34 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.33 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.32 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.31 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.30 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.29 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.28 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.27 app/controllers/workarea/storefront/errors_controller.rb
workarea-storefront-3.4.26 app/controllers/workarea/storefront/errors_controller.rb