Skip to content

Commit

Permalink
Make Twitter::Error#wrapped_exception interface consistent with Ruby 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 4, 2014
1 parent 47a11b5 commit c9fbd3e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ does not work on Ruby 2.0.0][bug].
[tweetstream]: http://rubygems.org/gems/tweetstream
[bug]: https://github.com/tweetstream/tweetstream/issues/117

Site Streams are restricted to whitelisted accounts. To apply for access to
Site Streams see the "Applying for access" section in the Site Streams Twitter
API [here][twitter]. User Streams, however, are open and do not require approval.
Site Streams are restricted to whitelisted accounts. To apply for access,
[follow the steps in the Site Streams documentation][site-streams]. [User
Streams][user-streams] do not require prior approval.

[twitter]: https://dev.twitter.com/docs/streaming-apis/streams/site#Applying_for_access
[site-streams]: https://dev.twitter.com/docs/streaming-apis/streams/site#Applying_for_access
[user-streams]: https://dev.twitter.com/docs/streaming-apis/streams/user

Unlike the rest of this library, this feature is not well tested and not
recommended for production applications. That said, if you need to do Twitter
Expand Down
7 changes: 4 additions & 3 deletions lib/twitter/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module Twitter
# Custom error class for rescuing from all Twitter errors
class Error < StandardError
extend DescendantsTracker
attr_reader :rate_limit, :wrapped_exception, :code
attr_reader :cause, :code, :rate_limit
alias_method :wrapped_exception, :cause

# If error code is missing see https://dev.twitter.com/docs/error-codes-responses
module Codes
Expand Down Expand Up @@ -75,9 +76,9 @@ def extract_message_from_errors(body)
# @param response_headers [Hash]
# @param code [Integer]
# @return [Twitter::Error]
def initialize(exception = $ERROR_INFO, response_headers = {}, code = nil) # rubocop:disable MethodLength
def initialize(exception = $ERROR_INFO, response_headers = {}, code = nil)
@rate_limit = RateLimit.new(response_headers)
@wrapped_exception = exception
@cause = exception
@code = code
exception.respond_to?(:message) ? super(exception.message) : super(exception.to_s)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def request(method, path, params = {}, signature_params = params) # rubocop:disa
end
response.env
rescue Faraday::Error::ClientError, JSON::ParserError => error
raise Twitter::Error.new(error)
raise Twitter::Error.new(error) # rubocop:disable RaiseArgs
end

def auth_token(method, path, params = {}, signature_params = params) # rubocop:disable ParameterLists
Expand Down

0 comments on commit c9fbd3e

Please sign in to comment.