390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
# File 'lib/client.rb', line 390
def verify_response_status(response, ignore_http_errors)
unless response.kind_of? String
http_status = response&.response&.code&.to_i || 500
is_success = (http_status >= 200 and http_status < 300)
if !is_success and !ignore_http_errors
title = "Request failed with status #{http_status}"
detail = response&.parsed_response["message"] || response&.response&.message || 'Unknown error'
if @debug
puts "Error detected: #{http_status}"
error_class = Errors::DynamicError.new(self, title, detail, http_status, response&.parsed_response)
raise error_class
end
response = JSON.generate(
{
'error' => {
'title' => title,
'status' => http_status
},
'message' => detail
}
)
end
end
response
end
|