Exception: Pickpoint::APIError
- Defined in:
- lib/pickpoint/errors.rb
Overview
Non-2xx public-api response (or transport failure after retries).
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #auth? ⇒ Boolean
- #conflict? ⇒ Boolean
-
#initialize(status: 0, code: "", message: "", body: "") ⇒ APIError
constructor
A new instance of APIError.
- #invalid_config? ⇒ Boolean
- #not_found? ⇒ Boolean
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 = .empty? ? "request failed (status=#{status} code=#{code})" : super("pickpoint: #{msg} (status=#{status} code=#{code})") end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
13 14 15 |
# File 'lib/pickpoint/errors.rb', line 13 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
13 14 15 |
# File 'lib/pickpoint/errors.rb', line 13 def code @code end |
#status ⇒ Object (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
23 24 25 |
# File 'lib/pickpoint/errors.rb', line 23 def auth? %w[API_AUTH REFRESH_FAILED].include?(code) end |
#conflict? ⇒ Boolean
31 32 33 |
# File 'lib/pickpoint/errors.rb', line 31 def conflict? code == "CONFLICT" end |
#invalid_config? ⇒ Boolean
35 36 37 |
# File 'lib/pickpoint/errors.rb', line 35 def invalid_config? code == "INVALID_CONFIG" end |
#not_found? ⇒ Boolean
27 28 29 |
# File 'lib/pickpoint/errors.rb', line 27 def not_found? code == "NOT_FOUND" end |