Exception: Pickpoint::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/pickpoint/errors.rb

Overview

Non-2xx public-api response (or transport failure after retries).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status: 0, code: "", message: "", body: "") ⇒ APIError

Returns a new instance of APIError.



15
16
17
18
19
20
21
# File 'lib/pickpoint/errors.rb', line 15

def initialize(status: 0, code: "", message: "", body: "")
  @status = status
  @code = code.to_s
  @body = body.is_a?(String) ? body.b : body.to_s.b
  msg = message.empty? ? "request failed (status=#{status} code=#{code})" : message
  super("pickpoint: #{msg} (status=#{status} code=#{code})")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



13
14
15
# File 'lib/pickpoint/errors.rb', line 13

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



13
14
15
# File 'lib/pickpoint/errors.rb', line 13

def code
  @code
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/pickpoint/errors.rb', line 13

def status
  @status
end

Instance Method Details

#auth?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/pickpoint/errors.rb', line 23

def auth?
  %w[API_AUTH REFRESH_FAILED].include?(code)
end

#conflict?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/pickpoint/errors.rb', line 31

def conflict?
  code == "CONFLICT"
end

#invalid_config?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/pickpoint/errors.rb', line 35

def invalid_config?
  code == "INVALID_CONFIG"
end

#not_found?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/pickpoint/errors.rb', line 27

def not_found?
  code == "NOT_FOUND"
end