Exception: Pipl::Client::APIError
- Inherits:
-
Exception
- Object
- Exception
- Pipl::Client::APIError
- Defined in:
- lib/pipl/errors.rb
Instance Attribute Summary collapse
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, status_code) ⇒ APIError
constructor
A new instance of APIError.
- #is_pipl_error? ⇒ Boolean
- #is_user_error? ⇒ Boolean
Constructor Details
#initialize(message, status_code) ⇒ APIError
Returns a new instance of APIError.
11 12 13 14 |
# File 'lib/pipl/errors.rb', line 11 def initialize(, status_code) super @status_code = status_code end |
Instance Attribute Details
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
9 10 11 |
# File 'lib/pipl/errors.rb', line 9 def status_code @status_code end |
Class Method Details
.from_json(json_str) ⇒ Object
24 25 26 27 |
# File 'lib/pipl/errors.rb', line 24 def self.from_json(json_str) h = JSON.parse(json_str, symbolize_names: true) self.new(h[:error], h[:@http_status_code]) end |
Instance Method Details
#is_pipl_error? ⇒ Boolean
20 21 22 |
# File 'lib/pipl/errors.rb', line 20 def is_pipl_error? not is_user_error? end |
#is_user_error? ⇒ Boolean
16 17 18 |
# File 'lib/pipl/errors.rb', line 16 def is_user_error? (400..499).member?(@status_code) end |