From 01a449b5cb1106a867a6b73cd4877e9b2ec68171 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 20 Oct 2016 11:27:05 +1300 Subject: netlib.exceptions.* -> mitmproxy.exceptions --- mitmproxy/exceptions.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'mitmproxy/exceptions.py') 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 -- cgit v1.2.3