diff options
author | Ilya Etingof <etingof@gmail.com> | 2018-07-10 22:19:41 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2018-08-06 09:16:50 +0200 |
commit | 853ba0bbf51060cbb45bda7b8deee678906c86f2 (patch) | |
tree | f9779743e955b886f14b7ef3c0c902525ea22284 /pysnmp/error.py | |
parent | 797b4fe6274d1fe240d38b4466c7e4c058d1df88 (diff) | |
download | pysnmp-git-853ba0bbf51060cbb45bda7b8deee678906c86f2.tar.gz |
Add PySnmpError.cause attribute
To convey parent exception information on re-raise
Diffstat (limited to 'pysnmp/error.py')
-rw-r--r-- | pysnmp/error.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pysnmp/error.py b/pysnmp/error.py index 3f546c79..b5bb35b5 100644 --- a/pysnmp/error.py +++ b/pysnmp/error.py @@ -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])) |