Sha256: f678181a1471927122afb1f73642787266f49f2cf2400b022137de527a13d6b7
Contents?: true
Size: 1.83 KB
Versions: 4
Compression:
Stored size: 1.83 KB
Contents
module Desk # Custom error class for rescuing from all Desk.com errors class Error < StandardError attr_reader :http_headers def initialize(message, http_headers) http_headers ||= {} @http_headers = Hash[http_headers] super message end def ratelimit_reset @http_headers.values_at('x-rate-limit-reset', 'X-Rate-Limit-Reset').detect {|value| value }.to_i end def ratelimit_limit @http_headers.values_at('x-rate-limit-limit', 'X-Rate-Limit-Limit').detect {|value| value }.to_i end def ratelimit_remaining @http_headers.values_at('x-rate-limit-remaining', 'X-Rate-Limit-Remaining').detect {|value| value }.to_i end def retry_after ratelimit_reset end end # Raised when Desk returns the HTTP status code 400 class BadRequest < Error; end # Raised when Desk returns the HTTP status code 401 class Unauthorized < Error; end # Raised when Desk returns the HTTP status code 403 class Forbidden < Error; end # Raised when Desk returns the HTTP status code 404 class NotFound < Error; end # Raised when Desk returns the HTTP status code 406 class NotAcceptable < Error; end # Raised when Desk returns the HTTP status code 429 # Called EnhanceYourCalm because TooManyRequests is taken (see below) class EnhanceYourCalm < Error; end # Raised when Desk max_requests is reached and use_max_requests is set to true class TooManyRequests < StandardError; end # Raised when Desk returns the HTTP status code 500 class InternalServerError < Error; end # Raised when Desk returns the HTTP status code 502 class BadGateway < Error; end # Raised when Desk returns the HTTP status code 503 class ServiceUnavailable < Error; end # Gem Specific Errors class DeskError < StandardError; end class SupportEmailNotSet < DeskError; end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
desk-1.0.4 | lib/desk/error.rb |
desk-1.0.3 | lib/desk/error.rb |
desk-1.0.2 | lib/desk/error.rb |
desk-1.0.1 | lib/desk/error.rb |