Improve exception hierarchy

ProxyException -> MitmproxyException
NetlibException inherits from MitmproxyException
This commit is contained in:
Aldo Cortesi 2016-10-20 11:29:53 +13:00
parent 01a449b5cb
commit 9491d8589a
2 changed files with 16 additions and 15 deletions

View File

@ -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.
"""

View File

@ -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