From 4291f76c9939a15838feed0b64230f4197ba844b Mon Sep 17 00:00:00 2001 From: Graham Dumpleton Date: Fri, 4 Oct 2013 16:07:11 +1000 Subject: [PATCH] Translate urllib3 ProxyError into a requests ProxyError derived from ConnectionError. --- requests/adapters.py | 6 +++++- requests/exceptions.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/requests/adapters.py b/requests/adapters.py index d557b74..7a0505b 100644 --- a/requests/adapters.py +++ b/requests/adapters.py @@ -22,8 +22,9 @@ from .packages.urllib3.exceptions import MaxRetryError from .packages.urllib3.exceptions import TimeoutError from .packages.urllib3.exceptions import SSLError as _SSLError from .packages.urllib3.exceptions import HTTPError as _HTTPError +from .packages.urllib3.exceptions import ProxyError as _ProxyError from .cookies import extract_cookies_to_jar -from .exceptions import ConnectionError, Timeout, SSLError +from .exceptions import ConnectionError, Timeout, SSLError, ProxyError from .auth import _basic_auth_str DEFAULT_POOLBLOCK = False @@ -353,6 +354,9 @@ class HTTPAdapter(BaseAdapter): except MaxRetryError as e: raise ConnectionError(e) + except _ProxyError as e: + raise ProxyError(e) + except (_SSLError, _HTTPError) as e: if isinstance(e, _SSLError): raise SSLError(e) diff --git a/requests/exceptions.py b/requests/exceptions.py index 22207e3..bc42b5f 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -27,6 +27,10 @@ class ConnectionError(RequestException): """A Connection error occurred.""" +class ProxyError(ConnectionError): + """A proxy error occurred.""" + + class SSLError(ConnectionError): """An SSL error occurred.""" -- 2.34.1