diff --git a/lib/active_utils/network_connection_retries.rb b/lib/active_utils/network_connection_retries.rb index f2d3541..6ee2edf 100644 --- a/lib/active_utils/network_connection_retries.rb +++ b/lib/active_utils/network_connection_retries.rb @@ -7,6 +7,7 @@ module NetworkConnectionRetries Timeout::Error => "The connection to the remote server timed out", Errno::ETIMEDOUT => "The connection to the remote server timed out", SocketError => "The connection to the remote server could not be established", + Errno::EHOSTUNREACH => "The connection to the remote server could not be established", OpenSSL::SSL::SSLError => "The SSL connection to the remote server could not be established" } diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb index 80ffed5..6eaa2da 100644 --- a/test/unit/network_connection_retries_test.rb +++ b/test/unit/network_connection_retries_test.rb @@ -48,13 +48,17 @@ def test_timeout_errors_raise_correctly end end - def test_socket_error_raises_correctly - raised = assert_raises(ActiveUtils::ConnectionError) do - retry_exceptions do - raise SocketError + def test_connection_errors_raise_correctly + exceptions = [SocketError, Errno::EHOSTUNREACH] + + exceptions.each do |exception| + raised = assert_raises(ActiveUtils::ConnectionError) do + retry_exceptions do + raise exception + end end + assert_equal "The connection to the remote server could not be established", raised.message end - assert_equal "The connection to the remote server could not be established", raised.message end def test_ssl_errors_raise_correctly