3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/change_health/change_health_exception.rb', line 3
def self.from_response(response, msg: nil)
exception_msg = "Failed #{msg}:"
exception_msg << " HTTP code: #{response.code} MSG: "
begin
error_response = response.parsed_response
if (error_response.is_a?(Hash) && error_response.include?("error_description"))
exception_msg << error_response["error_description"]
else
exception_msg << error_response
end
rescue JSON::ParserError
exception_msg << response.body
end
return ChangeHealthException.new(exception_msg)
end
|