From e21a4f69c68d28148045e7c98ce1841d72994e1e Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Wed, 8 Apr 2009 21:45:53 -0400 Subject: [PATCH] Fixed some issues in the exception raising. --- lib/twitter/request.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/twitter/request.rb b/lib/twitter/request.rb index e8717c333..93956e470 100644 --- a/lib/twitter/request.rb +++ b/lib/twitter/request.rb @@ -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