Exception: Desk::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Desk::Error
- Defined in:
- lib/desk/error.rb
Overview
Custom error class for rescuing from all Desk.com errors
Direct Known Subclasses
BadGateway, BadRequest, Conflict, EnhanceYourCalm, Forbidden, InternalServerError, NotAcceptable, NotFound, NotImplemented, ServiceUnavailable, Unauthorized, Unprocessable
Instance Attribute Summary collapse
-
#http_headers ⇒ Object
readonly
Returns the value of attribute http_headers.
Instance Method Summary collapse
-
#initialize(message, http_headers) ⇒ Error
constructor
A new instance of Error.
- #ratelimit_limit ⇒ Object
- #ratelimit_remaining ⇒ Object
- #ratelimit_reset ⇒ Object
- #retry_after ⇒ Object
Constructor Details
#initialize(message, http_headers) ⇒ Error
Returns a new instance of Error.
6 7 8 9 10 |
# File 'lib/desk/error.rb', line 6 def initialize(, http_headers) http_headers ||= {} @http_headers = Hash[http_headers] super end |
Instance Attribute Details
#http_headers ⇒ Object (readonly)
Returns the value of attribute http_headers.
4 5 6 |
# File 'lib/desk/error.rb', line 4 def http_headers @http_headers end |
Instance Method Details
#ratelimit_limit ⇒ Object
16 17 18 |
# File 'lib/desk/error.rb', line 16 def ratelimit_limit @http_headers.values_at('x-rate-limit-limit', 'X-Rate-Limit-Limit').detect {|value| value }.to_i end |
#ratelimit_remaining ⇒ Object
20 21 22 |
# File 'lib/desk/error.rb', line 20 def ratelimit_remaining @http_headers.values_at('x-rate-limit-remaining', 'X-Rate-Limit-Remaining').detect {|value| value }.to_i end |
#ratelimit_reset ⇒ Object
12 13 14 |
# File 'lib/desk/error.rb', line 12 def ratelimit_reset @http_headers.values_at('x-rate-limit-reset', 'X-Rate-Limit-Reset').detect {|value| value }.to_i end |
#retry_after ⇒ Object
24 25 26 |
# File 'lib/desk/error.rb', line 24 def retry_after ratelimit_reset end |