Sha256: a2300111aefa43fe148f44e12a4ad58143a4bd12612dee0d51c70d659db5b3bd

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Qismo
  # Qismo ruby base error
  #
  class Error < StandardError
    attr_reader :message
  end

  # Http timeout error
  #
  class HTTPTimeoutError < Error
    def initialize(message)
      super(message)
    end
  end

  # Http request error
  #
  class HTTPRequestError < Error
    attr_reader :message, :status_code, :response_body

    # Initiate error
    #
    # @param message [String]
    # @param status_code [Integer]
    # @param response_body [String]
    def initialize(message, status_code:, response_body:)
      super(message.to_s)

      @message = message
      @status_code = status_code
      @response_body = response_body
    end
  end

  # Http internal server error
  #
  class InternalServerError < HTTPRequestError
  end

  # Http 400 bad request error
  #
  class BadRequestError < HTTPRequestError
  end

  # Http 401 unauthorized error
  #
  class UnauthorizedError < HTTPRequestError
  end

  # Http 402 payment required error
  #
  class PaymentRequiredError < HTTPRequestError
  end

  # Http 403 forbidden error
  #
  class ForbiddenError < HTTPRequestError
  end

  # Http 404 not found error
  #
  class NotFoundError < HTTPRequestError
  end

  # Http 429 too many requests error
  #
  class TooManyRequestError < HTTPRequestError
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
qismo-0.11.3 lib/qismo/error.rb
qismo-0.11.2 lib/qismo/error.rb
qismo-0.11.1 lib/qismo/error.rb
qismo-0.11.0 lib/qismo/error.rb
qismo-0.10.0 lib/qismo/error.rb
qismo-0.9.0 lib/qismo/error.rb
qismo-0.8.8 lib/qismo/error.rb