Skip to content

Commit

Permalink
Fixed some issues in the exception raising.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Apr 9, 2009
1 parent 789aa38 commit e21a4f6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/twitter/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ def make_friendly(response)
def raise_errors(response)
case response.code.to_i
when 400
raise RateLimitExceeded.new(parse(response)), "(#{response.code}): #{response.message} - #{data['error']}"
data = parse(response)
raise RateLimitExceeded.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}"
when 401
data = parse(response)
raise Unauthorized.new(data), "(#{response.code}): #{response.message} - #{data['error']}"
raise Unauthorized.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}"
when 403
data = parse(response)
raise General.new(data), "(#{response.code}): #{response.message} - #{data['error']}"
raise General.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}"
when 404
raise NotFound, "(#{response.code}): #{response.message}"
when 500
Expand Down

0 comments on commit e21a4f6

Please sign in to comment.