Sha256: 9bae7195332dee70d4788e4d967fa9a0f499083348a0e11988e3f1016fd1c94d

Contents?: true

Size: 890 Bytes

Versions: 3

Compression:

Stored size: 890 Bytes

Contents

module Moromi
  module Error
    module Rescue
      extend ActiveSupport::Concern

      included do
        # 5xx error
        rescue_from Moromi::Error::Default, with: -> (e) { render_internal_server_error(exception: e) }

        # 4xx error
        rescue_from Moromi::Error::ValidationError, with: -> (e) { render_bad_request(exception: e) }
        rescue_from Moromi::Error::AuthenticationFailed, with: -> (e) { render_unauthorized(exception: e) }
        rescue_from Moromi::Error::PermissionDenied, with: -> (e) { render_forbidden(exception: e) }
        rescue_from Moromi::Error::NotFound, with: -> (e) { render_not_found(exception: e) }
        rescue_from Moromi::Error::TooManyRequests, with: -> (e) { render_too_many_requests(exception: e) }
        rescue_from Moromi::Error::NeedForceUpdate, with: -> (e) { render_force_update(exception: e) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moromi-error-0.5.0 lib/moromi/error/rescue.rb
moromi-error-0.4.0 lib/moromi/error/rescue.rb
moromi-error-0.3.0 lib/moromi/error/rescue.rb