Sha256: f71e178a06cda62bb4f29ea3fcec11086a35d7e34dd1158448f45df81d51011d
Contents?: true
Size: 1.22 KB
Versions: 52
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module IbrainHandler extend ActiveSupport::Concern included do rescue_from StandardError, with: :standard_handler rescue_from ActionController::ParameterMissing, with: :parameter_handler rescue_from ActiveRecord::RecordNotFound, with: :not_found_handler rescue_from ActiveRecord::RecordInvalid, with: :bad_request_handler rescue_from IbrainErrors::PermissionError, with: :permission_denied_handler rescue_from IbrainErrors::UnknownError, with: :bad_request_handler rescue_from ActionController::InvalidAuthenticityToken, with: :unauthorized_handler rescue_from ActiveSupport::MessageVerifier::InvalidSignature, with: :unauthorized_handler rescue_from GraphQL::ExecutionError, with: :bad_request_handler end private def standard_handler(errors) render_json_error(errors, 500) end def bad_request_handler(errors) render_json_error(errors, 400) end def parameter_handler(errors) render_json_error(errors, 400) end def not_found_handler(errors) render_json_error(errors, 404) end def permission_denied_handler(errors) render_json_error(errors, 405) end def unauthorized_handler(errors) render_json_error(errors, 401) end end
Version data entries
52 entries across 52 versions & 1 rubygems