Sha256: b9b192c954a4e664f9d2a3c5ac4fcc7f65a5f267d51e60455edc4adb46798481

Contents?: true

Size: 737 Bytes

Versions: 3

Compression:

Stored size: 737 Bytes

Contents

module Panda
  module CMS
    class ErrorsController < ApplicationController
      layout "error"

      def show
        exception = request.env["action_dispatch.exception"]
        status_code = exception.try(:status_code) || ActionDispatch::ExceptionWrapper.new(request.env, exception).status_code

        render view_for_code(status_code), status: status_code
      end

      def error_503
        render view_for_code(503), status: 503
      end

      private

      def view_for_code(code)
        supported_error_codes.fetch(code) { "404" }
      end

      def supported_error_codes
        {
          403 => "403",
          404 => "404",
          500 => "500",
          503 => "503"
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panda-cms-0.7.3 app/controllers/panda/cms/errors_controller.rb
panda-cms-0.7.2 app/controllers/panda/cms/errors_controller.rb
panda-cms-0.7.0 app/controllers/panda/cms/errors_controller.rb