Skip to content

Commit

Permalink
Remove descendants_tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 30, 2014
1 parent f48ecb9 commit 4cbcb0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 13 additions & 6 deletions lib/twitter/error.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require 'descendants_tracker'
require 'twitter/rate_limit'

module Twitter
# Custom error class for rescuing from all Twitter errors
class Error < StandardError
extend DescendantsTracker
attr_reader :cause, :code, :rate_limit
alias_method :wrapped_exception, :cause

Expand Down Expand Up @@ -42,10 +40,19 @@ def from_response(response = {})

# @return [Hash]
def errors
@errors ||= descendants.inject({}) do |hash, klass|
hash[klass::HTTP_STATUS_CODE] = klass
hash
end
@errors ||= {
400 => Twitter::Error::BadRequest,
401 => Twitter::Error::Unauthorized,
403 => Twitter::Error::Forbidden,
404 => Twitter::Error::NotFound,
406 => Twitter::Error::NotAcceptable,
422 => Twitter::Error::UnprocessableEntity,
429 => Twitter::Error::TooManyRequests,
500 => Twitter::Error::InternalServerError,
502 => Twitter::Error::BadGateway,
503 => Twitter::Error::ServiceUnavailable,
504 => Twitter::Error::GatewayTimeout,
}
end

private
Expand Down
1 change: 0 additions & 1 deletion twitter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require 'twitter/version'
Gem::Specification.new do |spec|
spec.add_dependency 'addressable', '~> 2.3'
spec.add_dependency 'buftok', '~> 0.2.0'
spec.add_dependency 'descendants_tracker', '~> 0.0.3'
spec.add_dependency 'equalizer', '~> 0.0.9'
spec.add_dependency 'faraday', '~> 0.9.0'
spec.add_dependency 'http', '~> 0.5.0'
Expand Down

0 comments on commit 4cbcb0f

Please sign in to comment.