28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/socketlabs/injectionapi/core/retryhandler.rb', line 28
def send(request)
attempts = 0
exception = nil
loop do
wait_interval = @retry_settings.get_next_wait_interval(attempts)
attempts += 1
begin
response = @http_client.send_request(request)
if @error_codes.include? response.status_code.to_i
exception = SocketLabs::InjectionApi::Exceptions::ServerException.new("Failed to send email. Received #{response.status_code} from server.")
sleep(wait_interval)
else
return response
end
rescue Timeout::Error => exception
exception = exception
break if attempts > @retry_settings.maximum_number_of_retries
sleep(wait_interval)
rescue Exception => exception
raise exception
end
break if attempts > @retry_settings.maximum_number_of_retries
end
raise exception if exception
false
end
|