Sha256: 170751e485b183dcb8626421387b7e21164f471e622d1a82371ee8603c387095
Contents?: true
Size: 1.32 KB
Versions: 20
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require 'active_record' require 'action_controller' module Lipstick module DynamicErrors Forbidden = Class.new(StandardError) private_constant :Forbidden Unauthorized = Class.new(StandardError) private_constant :Unauthorized BadRequest = Class.new(StandardError) private_constant :BadRequest NotFound = Class.new(StandardError) private_constant :NotFound def self.included(base) base.rescue_from Forbidden, with: :forbidden base.rescue_from Unauthorized, with: :unauthorized base.rescue_from BadRequest, with: :bad_request base.rescue_from NotFound, with: :not_found base.rescue_from(::ActiveRecord::RecordNotFound, with: :not_found) end private def not_found render 'dynamic_errors/not_found', status: :not_found, layout: 'application' end def unauthorized reset_session render 'dynamic_errors/unauthorized', status: :unauthorized, layout: 'application' end def forbidden render 'dynamic_errors/forbidden', status: :forbidden, layout: 'application' end def bad_request render 'dynamic_errors/bad_request', status: :bad_request, layout: 'application' end end end
Version data entries
20 entries across 20 versions & 1 rubygems