Sha256: e743d417bb9f22feeec150bd8ff4c7102a438ef1524397ebcc8b1a2fd34d7def

Contents?: true

Size: 874 Bytes

Versions: 6

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module Veryfi
  class Error
    def self.from_response(response)
      case response.status
      when 400 then BadRequest
      when 401 then UnauthorizedAccessToken
      when 405 then UnexpectedHTTPMethod
      when 409 then AccessLimitReached
      else InternalError
      end
    end

    class BadRequest < StandardError
      def to_s
        "Bad Request"
      end
    end

    class UnauthorizedAccessToken < StandardError
      def to_s
        "Unauthorized Access Token"
      end
    end

    class UnexpectedHTTPMethod < StandardError
      def to_s
        "Unexpected HTTP Method"
      end
    end

    class AccessLimitReached < StandardError
      def to_s
        "Access Limit Reached"
      end
    end

    class InternalError < StandardError
      def to_s
        "Internal Server Error"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
veryfi-1.0.0 lib/veryfi/error.rb
veryfi-0.1.4 lib/veryfi/error.rb
veryfi-0.1.3 lib/veryfi/error.rb
veryfi-0.1.2 lib/veryfi/error.rb
veryfi-0.1.1 lib/veryfi/error.rb
veryfi-0.1.0 lib/veryfi/error.rb