diff options
author | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:16:14 +0300 |
---|---|---|
committer | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:43:30 +0300 |
commit | b8cf9e88f4c5c64d9406af533d8948deb050d695 (patch) | |
tree | 218eb61fb3c3b96ec08b4d8cdfef383104a87d63 /contrib/python/Twisted/py2/twisted/protocols/haproxy/_exceptions.py | |
parent | 523f645a83a0ec97a0332dbc3863bb354c92a328 (diff) | |
download | ydb-b8cf9e88f4c5c64d9406af533d8948deb050d695.tar.gz |
add kikimr_configure
Diffstat (limited to 'contrib/python/Twisted/py2/twisted/protocols/haproxy/_exceptions.py')
-rw-r--r-- | contrib/python/Twisted/py2/twisted/protocols/haproxy/_exceptions.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/contrib/python/Twisted/py2/twisted/protocols/haproxy/_exceptions.py b/contrib/python/Twisted/py2/twisted/protocols/haproxy/_exceptions.py new file mode 100644 index 0000000000..8633ca4eec --- /dev/null +++ b/contrib/python/Twisted/py2/twisted/protocols/haproxy/_exceptions.py @@ -0,0 +1,52 @@ +# -*- test-case-name: twisted.protocols.haproxy.test -*- +# Copyright (c) Twisted Matrix Laboratories. +# See LICENSE for details. + +""" +HAProxy specific exceptions. +""" + +import contextlib +import sys + +from twisted.python import compat + + +class InvalidProxyHeader(Exception): + """ + The provided PROXY protocol header is invalid. + """ + + + +class InvalidNetworkProtocol(InvalidProxyHeader): + """ + The network protocol was not one of TCP4 TCP6 or UNKNOWN. + """ + + + +class MissingAddressData(InvalidProxyHeader): + """ + The address data is missing or incomplete. + """ + + + +@contextlib.contextmanager +def convertError(sourceType, targetType): + """ + Convert an error into a different error type. + + @param sourceType: The type of exception that should be caught and + converted. + @type sourceType: L{Exception} + + @param targetType: The type of exception to which the original should be + converted. + @type targetType: L{Exception} + """ + try: + yield None + except sourceType: + compat.reraise(targetType(), sys.exc_info()[-1]) |