Sha256: 73408002af102020fc52a08fa02c652b71fe9df24acfb5e145d2213d3a16e6ed

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

module Bamboozled
  class HTTPError < StandardError
    attr_reader :response
    attr_reader :params
    attr_reader :hint

    def initialize(response, params = {}, hint = nil)
      @response = response
      @params = params
      @hint = hint
      super(response)
    end

    def to_s
      "#{self.class.to_s} : #{response.code} #{response.body}" + (hint ? "\n#{hint}" : "")
    end
  end

  # 400
  class BadRequest < HTTPError; end #400
  class Unauthorized < HTTPError ; end #
  class Forbidden < HTTPError ; end # 403
  class NotFound < HTTPError; end # 404
  class NotAcceptable < HTTPError; end # 406
  class Conflict < HTTPError; end # 409
  class LimitExceeded < HTTPError; end # 429
  class InternalServerError < HTTPError; end # 500
  class GatewayError < HTTPError; end # 502
  class ServiceUnavailable < HTTPError; end # 503
  class InformBamboo < HTTPError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bamboozled-0.0.2 lib/bamboozled/errors.rb