Add PySnmpError.cause attribute

To convey parent exception information on re-raise
pull/186/head
Ilya Etingof 2018-07-10 22:19:41 +02:00
parent 797b4fe627
commit 853ba0bbf5
2 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
Revision 5.0.0, released 2018-07-??
Revision 5.0.0, released 2018-09-??
-----------------------------------
- SNMPv3 crypto operations that require external dependencies
@ -27,9 +27,10 @@ Revision 5.0.0, released 2018-07-??
methods. The goal is to let MIB objects access/modify whatever
custom Python objects they need while being called back.
Revision 4.4.5, released 2018-07-XX
Revision 4.4.5, released 2018-08-XX
-----------------------------------
- Added PySnmpError.cause attribute holding parent exception tuple
- Fixed zero SNMPv3 boots/time values put in SNMPv3 TRAP messages
- Fixed broken InetAddressType rendering caused by a pyasn1 regression
- Fixed typo in RFC1158 module

View File

@ -5,6 +5,10 @@
# License: http://snmplabs.com/pysnmp/license.html
#
import sys
class PySnmpError(Exception):
pass
def __init__(self, message):
self.cause = sys.exc_info()
Exception.__init__(self, '%s, caused by %s: %s' % (message, self.cause[0], self.cause[1]))