aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/exceptions.py
diff options
context:
space:
mode:
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