Skip to content
Snippets Groups Projects
Verified Commit 0ef2fb5f authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Return correct error data for 500 responses

parent 13a86c78
No related branches found
No related tags found
No related merge requests found
Pipeline #104362 passed
......@@ -41,6 +41,8 @@ module LiudeskCMDB
NotAcceptableError.new body, code
when "422"
UnprocessableError.new body, code
when "500"
ServerError.new body, code
else
RequestError.new body, code
end
......
......@@ -80,14 +80,14 @@ module LiudeskCMDB
response.body
rescue Net::HTTPClientException, Net::HTTPFatalError
begin
body = JSON.parse(response.body) unless response.body.empty?
resp = JSON.parse(response.body) unless response.body.empty?
rescue StandardError => e
logger.debug "Failed to parse error response - #{e.class}: #{e}"
body = response.body
body = response.message if body.nil? || body.empty?
resp = response.body
resp = response.message if resp.nil? || resp.empty?
end
raise LiudeskCMDB::RequestError.create(body, response.code)
raise LiudeskCMDB::RequestError.create(resp, response.code)
end
def pretty_print_instance_variables
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment