Sha256: 7293cfa031b6aba7ae0b3e92bc1d222d3409ca8a9123ba3be58362e91179d552

Contents?: true

Size: 700 Bytes

Versions: 7

Compression:

Stored size: 700 Bytes

Contents

module Bright
  class ResponseError < StandardError
    attr_reader :response
    attr_reader :uri

    def initialize(response, uri = nil)
      @response = response
      @uri = uri
    end

    def to_s
      "Failed with #{response.code} #{response.message if response.respond_to?(:message)}".strip
    end

    def body
      response.body
    end

    def server_error?
      (500..599).include?(response&.code.to_i)
    end

  end

  class UnknownAttributeError < NoMethodError
    attr_reader :record, :attribute

    def initialize(record, attribute)
      @record = record
      @attribute = attribute
      super("unknown attribute '#{attribute}' for #{@record.class}.")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bright-1.3 lib/bright/errors.rb
bright-1.2.3 lib/bright/errors.rb
bright-1.2.2 lib/bright/errors.rb
bright-1.2.1 lib/bright/errors.rb
bright-1.2 lib/bright/errors.rb
bright-1.1 lib/bright/errors.rb
bright-1.0 lib/bright/errors.rb