lib/paid/api_method.rb in paid-1.0.2 vs lib/paid/api_method.rb in paid-1.0.3

- old
+ new

@@ -44,10 +44,15 @@ def response_json begin json = Util.symbolize_keys(JSON.parse(@response_body)) rescue JSON::ParserError - raise APIError.new("Unable to parse the server response as JSON.", self) + if @response_body.is_a?(String) && @response_body.strip.empty? + {} + else + @error = APIError.new("Unable to parse the server response as JSON.", self) + raise @error + end end end def compose_error(error) msg = "An error occured while making the API call."