aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-10-20 11:29:53 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-10-20 11:31:18 +1300
commit9491d8589a265be33a5d6fac92c1213fd5b719d4 (patch)
tree83f5c8de0266fde2e6c68a799affc26d3a040131
parent01a449b5cb1106a867a6b73cd4877e9b2ec68171 (diff)
downloadmitmproxy-9491d8589a265be33a5d6fac92c1213fd5b719d4.tar.gz
mitmproxy-9491d8589a265be33a5d6fac92c1213fd5b719d4.tar.bz2
mitmproxy-9491d8589a265be33a5d6fac92c1213fd5b719d4.zip
Improve exception hierarchy
ProxyException -> MitmproxyException NetlibException inherits from MitmproxyException
-rw-r--r--mitmproxy/exceptions.py30
-rw-r--r--mitmproxy/proxy/protocol/rawtcp.py1
2 files changed, 16 insertions, 15 deletions
diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py
index 82022d31..a7ecf17f 100644
--- a/mitmproxy/exceptions.py
+++ b/mitmproxy/exceptions.py
@@ -2,7 +2,7 @@
We try to be very hygienic regarding the exceptions we throw:
- Every exception that might be externally visible to users shall be a subclass
- of ProxyException.p
+ of MitmproxyException.p
- Every exception in the base net module shall be a subclass
of NetlibException, and will not be propagated directly to users.
@@ -10,7 +10,7 @@ See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/
"""
-class ProxyException(Exception):
+class MitmproxyException(Exception):
"""
Base class for all exceptions thrown by mitmproxy.
@@ -20,7 +20,7 @@ class ProxyException(Exception):
super().__init__(message)
-class Kill(ProxyException):
+class Kill(MitmproxyException):
"""
Signal that both client and server connection(s) should be killed immediately.
@@ -28,7 +28,7 @@ class Kill(ProxyException):
pass
-class ProtocolException(ProxyException):
+class ProtocolException(MitmproxyException):
"""
ProtocolExceptions are caused by invalid user input, unavailable network resources,
or other events that are outside of our influence.
@@ -69,48 +69,48 @@ class Http2ZombieException(ProtocolException):
pass
-class ServerException(ProxyException):
+class ServerException(MitmproxyException):
pass
-class ContentViewException(ProxyException):
+class ContentViewException(MitmproxyException):
pass
-class ReplayException(ProxyException):
+class ReplayException(MitmproxyException):
pass
-class FlowReadException(ProxyException):
+class FlowReadException(MitmproxyException):
pass
-class ControlException(ProxyException):
+class ControlException(MitmproxyException):
pass
-class SetServerNotAllowedException(ProxyException):
+class SetServerNotAllowedException(MitmproxyException):
pass
-class OptionsError(Exception):
+class OptionsError(MitmproxyException):
pass
-class AddonError(Exception):
+class AddonError(MitmproxyException):
pass
-class AddonHalt(Exception):
+class AddonHalt(MitmproxyException):
pass
"""
- Every net Exception raised shall be a subclass of NetlibException.
+ Net-layer exceptions
"""
-class NetlibException(Exception):
+class NetlibException(MitmproxyException):
"""
Base class for all exceptions thrown by netlib.
"""
diff --git a/mitmproxy/proxy/protocol/rawtcp.py b/mitmproxy/proxy/protocol/rawtcp.py
index d117fb41..8230c50b 100644
--- a/mitmproxy/proxy/protocol/rawtcp.py
+++ b/mitmproxy/proxy/protocol/rawtcp.py
@@ -5,6 +5,7 @@ from OpenSSL import SSL
import netlib.tcp
from mitmproxy import tcp
from mitmproxy import flow
+from mitmproxy import exceptions
from mitmproxy.proxy.protocol import base