Skip to content

Commit

Permalink
Prevent MultiJson::DecodeError error from bubbling up
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jul 26, 2012
1 parent c2f6dc7 commit d870b7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/twitter/api.rb
Expand Up @@ -319,8 +319,8 @@ def update_profile_image(image, options={})
# @example Return the settings for the authenticating user.
# Twitter.settings
def settings(options={})
method = options.size.zero? ? :get : :post
object_from_response(Twitter::Settings, method, "1/account/settings.json", options)
request_method = options.size.zero? ? :get : :post
object_from_response(Twitter::Settings, request_method, "1/account/settings.json", options)
end

# Returns activity about me
Expand Down
3 changes: 3 additions & 0 deletions lib/twitter/client.rb
Expand Up @@ -2,6 +2,7 @@
require 'twitter/api'
require 'twitter/configurable'
require 'twitter/error/client_error'
require 'twitter/error/decode_error'
require 'twitter/rate_limit'
require 'simple_oauth'
require 'uri'
Expand Down Expand Up @@ -82,6 +83,8 @@ def request(method, path, params={}, options={})
response
rescue Faraday::Error::ClientError
raise Twitter::Error::ClientError
rescue MultiJson::DecodeError
raise Twitter::Error::DecodeError
end

def auth_header(method, uri, params={})
Expand Down
9 changes: 9 additions & 0 deletions lib/twitter/error/decode_error.rb
@@ -0,0 +1,9 @@
require 'twitter/error'

module Twitter
class Error
# Raised when JSON parsing fails
class DecodeError < Twitter::Error
end
end
end

0 comments on commit d870b7b

Please sign in to comment.