diff --git a/botocore/exceptions.py b/botocore/exceptions.py index e807dec7b1..a1f4fa256b 100644 --- a/botocore/exceptions.py +++ b/botocore/exceptions.py @@ -77,7 +77,7 @@ class EndpointConnectionError(HTTPClientError): fmt = 'Could not connect to the endpoint URL: "{endpoint_url}"' -class SSLError(ConnectionError): +class SSLError(ConnectionError, requests.exceptions.SSLError): fmt = 'SSL validation failed for {endpoint_url} {error}' diff --git a/tests/unit/test_http_client_exception_mapping.py b/tests/unit/test_http_client_exception_mapping.py new file mode 100644 index 0000000000..9eee38c46b --- /dev/null +++ b/tests/unit/test_http_client_exception_mapping.py @@ -0,0 +1,27 @@ +from nose.tools import assert_raises + +from botocore import exceptions as botocore_exceptions +from botocore.vendored.requests import exceptions as requests_exceptions +from botocore.vendored.requests.packages.urllib3 import exceptions as urllib3_exceptions + +EXCEPTION_MAPPING = [ + (botocore_exceptions.ReadTimeoutError, requests_exceptions.ReadTimeout), + (botocore_exceptions.ReadTimeoutError, urllib3_exceptions.ReadTimeoutError), + (botocore_exceptions.ConnectTimeoutError, requests_exceptions.ConnectTimeout), + (botocore_exceptions.ProxyConnectionError, requests_exceptions.ProxyError), + (botocore_exceptions.SSLError, requests_exceptions.SSLError), +] + + +def _raise_exception(exception): + raise exception(endpoint_url=None, proxy_url=None, error=None) + + +def _test_exception_mapping(new_exception, old_exception): + # assert that the new exception can still be caught by the old vendored one + assert_raises(old_exception, _raise_exception, new_exception) + + +def test_http_client_exception_mapping(): + for new_exception, old_exception in EXCEPTION_MAPPING: + yield _test_exception_mapping, new_exception, old_exception