Sha256: f5de00a52f5a0643a77622f6d2cacd9ec474b99648b3e6c8c0d4f8e4999b2552

Contents?: true

Size: 809 Bytes

Versions: 15

Compression:

Stored size: 809 Bytes

Contents

module LinkedIn
  class Error < StandardError
    extend Forwardable

    attr_accessor :request, :response
    delegate [:status, :body] => :response

    def initialize(error_data={})
      if hash = Hash.try_convert(error_data)
        self.request, self.response = hash[:request], hash[:response]
      end

      super (self.response && self.response.body['message']) || error_data
    end
  end

  class BadRequest < Error; end
  class Unauthorized < Error; end
  class Forbidden < Error; end
  class NotFound < Error; end
  class InternalServerError < Error; end

  class CSRF < Error
    def initialize(expected=nil, received=nil)
      additional = "Excepted '#{expected}' but received '#{received}'" if expected
      super "Response state did not match sent state. #{additional}"
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
linkedin2-0.0.16 lib/linkedin/error.rb
linkedin2-0.0.15 lib/linkedin/error.rb
linkedin2-0.0.14 lib/linkedin/error.rb
linkedin2-0.0.13 lib/linkedin/error.rb
linkedin2-0.0.12 lib/linkedin/error.rb
linkedin2-0.0.11 lib/linkedin/error.rb
linkedin2-0.0.10 lib/linkedin/error.rb
linkedin2-0.0.9 lib/linkedin/error.rb
linkedin2-0.0.8 lib/linkedin/error.rb
linkedin2-0.0.7 lib/linkedin/error.rb
linkedin2-0.0.6 lib/linkedin/error.rb
linkedin2-0.0.5 lib/linkedin/error.rb
linkedin2-0.0.4 lib/linkedin/error.rb
linkedin2-0.0.3 lib/linkedin/error.rb
linkedin2-0.0.2 lib/linkedin/error.rb