aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/exceptions.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-10-20 11:27:05 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-10-20 11:27:05 +1300
commit01a449b5cb1106a867a6b73cd4877e9b2ec68171 (patch)
tree5a213fb4b8199d525079a55b64d6d232380be341 /mitmproxy/exceptions.py
parent301d52d9d05f2c5f074fe68c73acc1c32e518020 (diff)
downloadmitmproxy-01a449b5cb1106a867a6b73cd4877e9b2ec68171.tar.gz
mitmproxy-01a449b5cb1106a867a6b73cd4877e9b2ec68171.tar.bz2
mitmproxy-01a449b5cb1106a867a6b73cd4877e9b2ec68171.zip
netlib.exceptions.* -> mitmproxy.exceptions
Diffstat (limited to 'mitmproxy/exceptions.py')
-rw-r--r--mitmproxy/exceptions.py62
1 files changed, 61 insertions, 1 deletions
diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py
index 64cc457a..82022d31 100644
--- a/mitmproxy/exceptions.py
+++ b/mitmproxy/exceptions.py
@@ -1,7 +1,10 @@
"""
We try to be very hygienic regarding the exceptions we throw:
-Every Exception mitmproxy raises shall be a subclass of ProxyException.
+- Every exception that might be externally visible to users shall be a subclass
+ of ProxyException.p
+- Every exception in the base net module shall be a subclass
+ of NetlibException, and will not be propagated directly to users.
See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/
"""
@@ -100,3 +103,60 @@ class AddonError(Exception):
class AddonHalt(Exception):
pass
+
+
+"""
+ Every net Exception raised shall be a subclass of NetlibException.
+"""
+
+
+class NetlibException(Exception):
+ """
+ Base class for all exceptions thrown by netlib.
+ """
+ def __init__(self, message=None):
+ super().__init__(message)
+
+
+class Disconnect:
+ """Immediate EOF"""
+
+
+class HttpException(NetlibException):
+ pass
+
+
+class HttpReadDisconnect(HttpException, Disconnect):
+ pass
+
+
+class HttpSyntaxException(HttpException):
+ pass
+
+
+class TcpException(NetlibException):
+ pass
+
+
+class TcpDisconnect(TcpException, Disconnect):
+ pass
+
+
+class TcpReadIncomplete(TcpException):
+ pass
+
+
+class TcpTimeout(TcpException):
+ pass
+
+
+class TlsException(NetlibException):
+ pass
+
+
+class InvalidCertificateException(TlsException):
+ pass
+
+
+class Timeout(TcpException):
+ pass