Exception: Pipl::Client::APIError
- Inherits:
-
Exception
- Object
- Exception
- Pipl::Client::APIError
- Defined in:
- lib/pipl/errors.rb
Instance Attribute Summary collapse
-
#demo_usage_allotted ⇒ Object
readonly
Returns the value of attribute demo_usage_allotted.
-
#demo_usage_current ⇒ Object
readonly
Returns the value of attribute demo_usage_current.
-
#demo_usage_expiry ⇒ Object
readonly
Returns the value of attribute demo_usage_expiry.
-
#qps_allotted ⇒ Object
readonly
Returns the value of attribute qps_allotted.
-
#qps_current ⇒ Object
readonly
Returns the value of attribute qps_current.
-
#qps_demo_allotted ⇒ Object
readonly
Returns the value of attribute qps_demo_allotted.
-
#qps_demo_current ⇒ Object
readonly
Returns the value of attribute qps_demo_current.
-
#qps_live_allotted ⇒ Object
readonly
Returns the value of attribute qps_live_allotted.
-
#qps_live_current ⇒ Object
readonly
Returns the value of attribute qps_live_current.
-
#quota_allotted ⇒ Object
readonly
Returns the value of attribute quota_allotted.
-
#quota_current ⇒ Object
readonly
Returns the value of attribute quota_current.
-
#quota_reset ⇒ Object
readonly
Returns the value of attribute quota_reset.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
- .deserialize(json_str, headers = {}) ⇒ Object
- .from_http_response(resp) ⇒ Object
-
.from_json(json_str) ⇒ Object
Here for backward compatibility.
Instance Method Summary collapse
-
#initialize(message, status_code, params = {}) ⇒ APIError
constructor
A new instance of APIError.
- #is_pipl_error? ⇒ Boolean
- #is_user_error? ⇒ Boolean
Constructor Details
#initialize(message, status_code, params = {}) ⇒ APIError
Returns a new instance of APIError.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pipl/errors.rb', line 14 def initialize(, status_code, params={}) super @status_code = status_code @qps_allotted = params[:qps_allotted] @qps_current = params[:qps_current] @qps_live_allotted = params[:qps_live_allotted] @qps_live_current = params[:qps_live_current] @qps_demo_allotted = params[:qps_demo_allotted] @qps_demo_current = params[:qps_demo_current] @quota_allotted = params[:quota_allotted] @quota_current = params[:quota_current] @quota_reset = params[:quota_reset] @demo_usage_allotted = params[:demo_usage_allotted] @demo_usage_current = params[:demo_usage_current] @demo_usage_expiry = params[:demo_usage_expiry] end |
Instance Attribute Details
#demo_usage_allotted ⇒ Object (readonly)
Returns the value of attribute demo_usage_allotted.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def demo_usage_allotted @demo_usage_allotted end |
#demo_usage_current ⇒ Object (readonly)
Returns the value of attribute demo_usage_current.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def demo_usage_current @demo_usage_current end |
#demo_usage_expiry ⇒ Object (readonly)
Returns the value of attribute demo_usage_expiry.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def demo_usage_expiry @demo_usage_expiry end |
#qps_allotted ⇒ Object (readonly)
Returns the value of attribute qps_allotted.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def qps_allotted @qps_allotted end |
#qps_current ⇒ Object (readonly)
Returns the value of attribute qps_current.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def qps_current @qps_current end |
#qps_demo_allotted ⇒ Object (readonly)
Returns the value of attribute qps_demo_allotted.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def qps_demo_allotted @qps_demo_allotted end |
#qps_demo_current ⇒ Object (readonly)
Returns the value of attribute qps_demo_current.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def qps_demo_current @qps_demo_current end |
#qps_live_allotted ⇒ Object (readonly)
Returns the value of attribute qps_live_allotted.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def qps_live_allotted @qps_live_allotted end |
#qps_live_current ⇒ Object (readonly)
Returns the value of attribute qps_live_current.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def qps_live_current @qps_live_current end |
#quota_allotted ⇒ Object (readonly)
Returns the value of attribute quota_allotted.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def quota_allotted @quota_allotted end |
#quota_current ⇒ Object (readonly)
Returns the value of attribute quota_current.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def quota_current @quota_current end |
#quota_reset ⇒ Object (readonly)
Returns the value of attribute quota_reset.
10 11 12 |
# File 'lib/pipl/errors.rb', line 10 def quota_reset @quota_reset end |
#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
.deserialize(json_str, headers = {}) ⇒ Object
39 40 41 42 43 |
# File 'lib/pipl/errors.rb', line 39 def self.deserialize(json_str, headers={}) h = JSON.parse(json_str, symbolize_names: true) params = Utils::extract_rate_limits(headers) self.new(h[:error], h[:@http_status_code], params) end |
.from_http_response(resp) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/pipl/errors.rb', line 45 def self.from_http_response(resp) begin self.deserialize(resp.body, resp) rescue Pipl::Client::APIError.new resp., resp.code end end |
.from_json(json_str) ⇒ Object
Here for backward compatibility
54 55 56 |
# File 'lib/pipl/errors.rb', line 54 def self.from_json(json_str) self.deserialize(json_str) end |
Instance Method Details
#is_pipl_error? ⇒ Boolean
35 36 37 |
# File 'lib/pipl/errors.rb', line 35 def is_pipl_error? ! is_user_error? end |
#is_user_error? ⇒ Boolean
31 32 33 |
# File 'lib/pipl/errors.rb', line 31 def is_user_error? (400..499).member?(@status_code) end |