Exception: AngellistApi::Error
- Inherits:
-
StandardError
- Object
- StandardError
- AngellistApi::Error
- Defined in:
- lib/angellist_api/error.rb,
lib/angellist_api/error/too_many_requests.rb
Overview
Note:
We’ve inquired with the AngelList API team about using a 429 status in the future.
Raised when AngellistApi returns the HTTP status code 403 with “over_limit” in the response.
Direct Known Subclasses
BadGateway, BadRequest, Forbidden, InternalServerError, NotAcceptable, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized
Defined Under Namespace
Classes: BadGateway, BadRequest, Forbidden, InternalServerError, NotAcceptable, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized
Constant Summary collapse
- EnhanceYourCalm =
Backwards compatability
TooManyRequests
Instance Attribute Summary collapse
-
#http_headers ⇒ Object
readonly
Returns the value of attribute http_headers.
Instance Method Summary collapse
-
#initialize(message, http_headers = {}) ⇒ AngellistApi::Error
constructor
Initializes new Error object.
- #ratelimit_limit ⇒ Integer
- #ratelimit_remaining ⇒ Integer
- #ratelimit_reset ⇒ Time
- #retry_after ⇒ Integer
Constructor Details
#initialize(message, http_headers = {}) ⇒ AngellistApi::Error
Initializes new Error object
11 12 13 14 |
# File 'lib/angellist_api/error.rb', line 11 def initialize(, http_headers={}) @http_headers = http_headers super end |
Instance Attribute Details
#http_headers ⇒ Object (readonly)
Returns the value of attribute http_headers.
4 5 6 |
# File 'lib/angellist_api/error.rb', line 4 def http_headers @http_headers end |
Instance Method Details
#ratelimit_limit ⇒ Integer
23 24 25 26 |
# File 'lib/angellist_api/error.rb', line 23 def ratelimit_limit limit = http_headers['x-ratelimit-limit'] limit.to_i if limit end |
#ratelimit_remaining ⇒ Integer
29 30 31 32 |
# File 'lib/angellist_api/error.rb', line 29 def ratelimit_remaining remaining = http_headers['x-ratelimit-remaining'] remaining.to_i if remaining end |
#ratelimit_reset ⇒ Time
17 18 19 20 |
# File 'lib/angellist_api/error.rb', line 17 def ratelimit_reset reset = http_headers['x-ratelimit-reset'] Time.at(reset.to_i) if reset end |
#retry_after ⇒ Integer
35 36 37 |
# File 'lib/angellist_api/error.rb', line 35 def retry_after [(ratelimit_reset - Time.now).ceil, 0].max if ratelimit_reset end |