summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-08-05 09:56:41 +0200
committerGitHub <noreply@github.com>2018-08-05 09:56:41 +0200
commit36f7584402aa8f1c3da538f2f331e980344c719a (patch)
treec5215e370e8648f451f6a8182d6657ba612d2ced
parentee321e04796d0a6874ae85385a5df00aa76f8066 (diff)
downloadpysnmp-git-36f7584402aa8f1c3da538f2f331e980344c719a.tar.gz
Add PySnmpError.cause attribute (#168)
To convey parent exception information on re-raise
-rw-r--r--CHANGES.txt1
-rw-r--r--pysnmp/error.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 009f6f34..66a78e9d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
Revision 4.4.5, released 2018-04-XX
-----------------------------------
+- Added PySnmpError.cause attribute holding parent exception tuple
- Fixed broken InetAddressType rendering caused by a pyasn1 regression
- Fixed typo in RFC1158 module
- Fixed possible infinite loop in GETBULK response PDU builder
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]))