Sha256: 08fdd19a0dc3f8b3af3fed6c8402d41245258dd0d9bb9cdcb829358669bd7291

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Rainmaker
  # Custom error class for rescuing from all Rainmaker errors
  class Error < StandardError
    attr_reader :http_headers

    def initialize(message, http_headers)
      @http_headers = Hash[http_headers]
      super message
    end
  end

  # Raised when Rainmaker returns the HTTP status code 400
  class BadRequest < Error; end

  # Raised when Rainmaker returns the HTTP status code 401
  class Unauthorized < Error; end

  # Raised when Rainmaker returns the HTTP status code 403
  class Forbidden < Error; end

  # Raised when Rainmaker returns the HTTP status code 404
  class NotFound < Error; end

  # Raised when Rainmaker returns the HTTP status code 422
  class Invalid < Error; end

  # Raised when Rainmaker returns the HTTP status code 500
  class InternalServerError < Error; end

  # Raised when Rainmaker returns the HTTP status code 502
  class BadGateway < Error; end

  # Raised when Rainmaker returns the HTTP status code 503
  class ServiceUnavailable < Error; end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rainmaker-0.1.5 lib/rainmaker/error.rb
rainmaker-0.1.4 lib/rainmaker/error.rb
rainmaker-0.1.3 lib/rainmaker/error.rb