Exception: Twitter::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Twitter::Error
- Defined in:
- lib/twitter/error.rb,
lib/twitter/error/forbidden.rb,
lib/twitter/error/not_found.rb,
lib/twitter/error/bad_gateway.rb,
lib/twitter/error/bad_request.rb,
lib/twitter/error/client_error.rb,
lib/twitter/error/server_error.rb,
lib/twitter/error/decode_error.rb,
lib/twitter/error/unauthorized.rb,
lib/twitter/error/not_acceptable.rb,
lib/twitter/error/gateway_timeout.rb,
lib/twitter/error/already_retweeted.rb,
lib/twitter/error/too_many_requests.rb,
lib/twitter/error/already_favorited.rb,
lib/twitter/error/service_unavailable.rb,
lib/twitter/error/configuration_error.rb,
lib/twitter/error/unprocessable_entity.rb,
lib/twitter/error/internal_server_error.rb,
lib/twitter/error/identity_map_key_error.rb
Overview
Custom error class for rescuing from all Twitter errors
Direct Known Subclasses
AlreadyFavorited, AlreadyRetweeted, ClientError, DecodeError, ServerError
Defined Under Namespace
Classes: AlreadyFavorited, AlreadyRetweeted, BadGateway, BadRequest, ClientError, ConfigurationError, DecodeError, Forbidden, GatewayTimeout, IdentityMapKeyError, InternalServerError, NotAcceptable, NotFound, ServerError, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity
Constant Summary
- EnhanceYourCalm =
TooManyRequests- RateLimited =
TooManyRequests
Instance Attribute Summary (collapse)
-
- (Object) rate_limit
readonly
Returns the value of attribute rate_limit.
-
- (Object) wrapped_exception
readonly
Returns the value of attribute wrapped_exception.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) backtrace
-
- (Twitter::Error) initialize(exception = $!, response_headers = {})
constructor
Initializes a new Error object.
Constructor Details
- (Twitter::Error) initialize(exception = $!, response_headers = {})
Initializes a new Error object
23 24 25 26 27 |
# File 'lib/twitter/error.rb', line 23 def initialize(exception=$!, response_headers={}) @rate_limit = Twitter::RateLimit.new(response_headers) @wrapped_exception = exception exception.respond_to?(:backtrace) ? super(exception.) : super(exception.to_s) end |
Instance Attribute Details
- (Object) rate_limit (readonly)
Returns the value of attribute rate_limit
6 7 8 |
# File 'lib/twitter/error.rb', line 6 def rate_limit @rate_limit end |
- (Object) wrapped_exception (readonly)
Returns the value of attribute wrapped_exception
6 7 8 |
# File 'lib/twitter/error.rb', line 6 def wrapped_exception @wrapped_exception end |
Class Method Details
+ (Array) descendants
14 15 16 |
# File 'lib/twitter/error.rb', line 14 def self.descendants ObjectSpace.each_object(::Class).select{|klass| klass < self} end |
+ (Hash) errors
9 10 11 |
# File 'lib/twitter/error.rb', line 9 def self.errors @errors ||= Hash[descendants.map{|klass| [klass.const_get(:HTTP_STATUS_CODE), klass]}] end |
Instance Method Details
- (Object) backtrace
29 30 31 |
# File 'lib/twitter/error.rb', line 29 def backtrace @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super end |