- """
- Exception for libcrypto errors. Adds all the info, which can be
- extracted from internal (per-thread) libcrypto error stack to the message,
- passed to the constructor.
- """
- def __init__(self,msg):
- global strings_loaded
- if not strings_loaded:
- libcrypto.ERR_load_crypto_strings()
- strings_loaded = True
- e=libcrypto.ERR_get_error()
- m = msg
- while e != 0:
- m+="\n\t"+libcrypto.ERR_lib_error_string(e)+":"+\
- libcrypto.ERR_func_error_string(e)+":"+\
- libcrypto.ERR_reason_error_string(e)
- e=libcrypto.ERR_get_error()
- self.args=(m,)
+ """
+ Exception for libcrypto errors. Adds all the info, which can be
+ extracted from internal (per-thread) libcrypto error stack to the message,
+ passed to the constructor.
+ """
+ def __init__(self, msg):
+ global strings_loaded
+ if not strings_loaded:
+ libcrypto.ERR_load_crypto_strings()
+ strings_loaded = True
+ err_code = libcrypto.ERR_get_error()
+ mesg = msg
+ buf = create_string_buffer(128)
+ while err_code != 0:
+ mesg += "\n\t" + libcrypto.ERR_error_string(err_code, buf)
+ err_code = libcrypto.ERR_get_error()
+ super(LibCryptoError, self).__init__(mesg)