commit f8e192f9798e8466fac59c0c03a4ae982b62e869 Author: Isis Lovecruft isis@torproject.org Date: Mon Apr 22 00:17:25 2013 +0000
Add dictionary of pre-defined error messages to SSLContextError.
* This help us make informative messages for the user and logs, later when setUp() is called, so that we can explain, for example, why we can't test TLS and SSLv2/SSLv3 simultaneously. --- nettests/experimental/tls_handshake.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py index 5d6d293..e84ffb8 100644 --- a/nettests/experimental/tls_handshake.py +++ b/nettests/experimental/tls_handshake.py @@ -82,10 +82,20 @@ class SSLContextError(usage.UsageError):
``SSLContextError('NO_CONTEXT')`` """ - pass
-class HostUnreachableError(Exception): - """Raised when there the host IP address appears to be unreachable.""" + #: Pre-defined error messages. + errors = { + 'NO_CONTEXT': 'No SSL/TLS context chosen! Defaulting to TLSv1.', + 'INCOMPATIBLE': str("Testing TLSv1 (option '--tls1') is incompatible " + + "with testing SSL ('--ssl2' and '--ssl3').") } + + def __init__(self, message): + if message in self.errors.keys(): + message = self.errors[message] + super(usage.UsageError, self).__init__(message) + +class HostUnreachable(Exception): + """Raised when the host IP address appears to be unreachable.""" pass
class ConnectionTimeout(Exception):