5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/etapi/error.rb', line 5
def check_response(response)
raise Error.new(-1, 'Network error') if response.class != Net::HTTPOK
response = Nokogiri::XML::Document.parse(response.body)
error_code = response.xpath("//error")
error_msg = response.xpath("//error_description")
if !error_code.blank? && !error_msg.blank?
if ETAPI.raise_errors?
raise(RuntimeError, "\n\n Code: #{error_code.text.to_i}\n Message: #{error_msg.text}\n\n")
else
ETAPI.log(" Code: #{error_code.text.to_i}\n Message: #{error_msg.text}") if ETAPI.log?
return false
end
end
end
|