def populate_error response
response.error = nil
status = response.http_response.status
code = nil
code = extract_error_code(response)
case
when response.timeout?
response.error = Timeout::Error.new
when code
response.error =
service_module::Errors.error_class(code).new(response.http_request,
response.http_response)
when status >= 500
response.error =
Errors::ServerError.new(response.http_request, response.http_response)
when status >= 300
response.error =
Errors::ClientError.new(response.http_request, response.http_response)
end
end