Exception: AngellistApi::Error

Inherits:
StandardError
  • Object
show all
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.

Defined Under Namespace

Classes: BadGateway, BadRequest, Forbidden, InternalServerError, NotAcceptable, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized

Constant Summary collapse

EnhanceYourCalm =

Backwards compatability

TooManyRequests

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, http_headers = {}) ⇒ AngellistApi::Error

Initializes new Error object

Parameters:

  • message (String)
  • http_headers (Hash) (defaults to: {})


11
12
13
14
# File 'lib/angellist_api/error.rb', line 11

def initialize(message, http_headers={})
  @http_headers = http_headers
  super message
end

Instance Attribute Details

#http_headersObject (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_limitInteger

Returns:

  • (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_remainingInteger

Returns:

  • (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_resetTime

Returns:

  • (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_afterInteger

Returns:

  • (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