Sha256: fbac09cddefe404dfcc32228f01409f7bc6ccd57794e2d9a4e4c2445881a7990

Contents?: true

Size: 1.36 KB

Versions: 6

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Qismo
  #
  # Qismo generic error
  # @!attribute message [String]
  #
  class Error < StandardError
  end

  #
  # Qismo HTTP error
  #
  # @attribute message [String]
  # @attribute http_code [Integer]
  # @attribute http_headers [Hash]
  # @attribute http_body [Hash,String]
  # @attribute http_raw_body [String]
  #
  class HTTPError < StandardError
    attr_accessor :message, :http_code, :http_headers, :http_body, :http_raw_body

    def initialize(message = nil, http_code: nil, http_headers: nil, http_body: nil, http_raw_body: nil)
      @message = message
      @http_code = http_code
      @http_headers = http_headers
      @http_body = http_body
      @http_raw_body = http_raw_body
    end
  end

  # Error for 5xx status code
  ServerError = Class.new(HTTPError)

  # Error for 500 status code
  InternalServerError = Class.new(ServerError)

  # Error for 4xx status code
  ClientError = Class.new(HTTPError)

  # Error for 400 status code
  BadRequest = Class.new(ClientError)

  # Error for 401 status code
  Unauthorized = Class.new(ClientError)

  # Error for 402 status code
  PaymentRequired = Class.new(ClientError)

  # Error for 403 status code
  Forbidden = Class.new(ClientError)

  # Error for 404 status code
  NotFound = Class.new(ClientError)

  # Error for 429 status code
  RateLimitExceeded = Class.new(ClientError)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
qismo-0.1.8 lib/qismo/errors.rb
qismo-0.1.5 lib/qismo/errors.rb
qismo-0.1.4 lib/qismo/errors.rb
qismo-0.1.2 lib/qismo/errors.rb
qismo-0.1.1 lib/qismo/errors.rb
qismo-0.1.0 lib/qismo/errors.rb