Exception: Twitter::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Twitter::Error
- Defined in:
- lib/twitter/error.rb,
lib/twitter/error/not_found.rb,
lib/twitter/error/forbidden.rb,
lib/twitter/error/bad_request.rb,
lib/twitter/error/bad_gateway.rb,
lib/twitter/error/decode_error.rb,
lib/twitter/error/client_error.rb,
lib/twitter/error/unauthorized.rb,
lib/twitter/error/server_error.rb,
lib/twitter/error/not_acceptable.rb,
lib/twitter/error/gateway_timeout.rb,
lib/twitter/error/too_many_requests.rb,
lib/twitter/error/already_retweeted.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
21 22 23 24 25 |
# File 'lib/twitter/error.rb', line 21 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
4 5 6 |
# File 'lib/twitter/error.rb', line 4 def rate_limit @rate_limit end |
- (Object) wrapped_exception (readonly)
Returns the value of attribute wrapped_exception
4 5 6 |
# File 'lib/twitter/error.rb', line 4 def wrapped_exception @wrapped_exception end |
Class Method Details
+ (Array) descendants
12 13 14 |
# File 'lib/twitter/error.rb', line 12 def self.descendants ObjectSpace.each_object(::Class).select{|klass| klass < self} end |
+ (Hash) errors
7 8 9 |
# File 'lib/twitter/error.rb', line 7 def self.errors @errors ||= Hash[descendants.map{|klass| [klass.const_get(:HTTP_STATUS_CODE), klass]}] end |
Instance Method Details
- (Object) backtrace
27 28 29 |
# File 'lib/twitter/error.rb', line 27 def backtrace @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super end |