lib/ruby_lokalise_api/request.rb in ruby-lokalise-api-9.0.1 vs lib/ruby_lokalise_api/request.rb in ruby-lokalise-api-9.2.0
- old
+ new
@@ -61,18 +61,20 @@
respond_with_error(response.status, body)
end
def respond_with(response, endpoint)
- begin
- body = custom_load response.body
- rescue JSON::ParserError
- respond_with_error(response.status, response.body)
- end
+ body = parse_response_body(response)
raise_on_error! response, body
RubyLokaliseApi::Response.new(body, endpoint, response.headers)
+ end
+
+ def parse_response_body(response)
+ custom_load(response.body)
+ rescue JSON::ParserError
+ respond_with_error(response.status, response.body)
end
def respond_with_error(code, body)
raise(RubyLokaliseApi::Error, body['error'] || body) unless RubyLokaliseApi::Error::ERRORS.key? code