summaryrefslogtreecommitdiff
path: root/pysnmp/error.py
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-08-05 10:24:50 +0200
committerIlya Etingof <etingof@gmail.com>2018-08-06 09:16:50 +0200
commit3b514f9aec31723587caa1475d38d836bf300563 (patch)
tree82c8c4b5cbcfe5d38b14969691807552ae71f2de /pysnmp/error.py
parent853ba0bbf51060cbb45bda7b8deee678906c86f2 (diff)
downloadpysnmp-git-3b514f9aec31723587caa1475d38d836bf300563.tar.gz
Fix PySnmpError implementation
This is a follow up fix to make PySnmpError properly overriding base Exception call signature
Diffstat (limited to 'pysnmp/error.py')
-rw-r--r--pysnmp/error.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/pysnmp/error.py b/pysnmp/error.py
index b5bb35b5..e47f4bcb 100644
--- a/pysnmp/error.py
+++ b/pysnmp/error.py
@@ -9,6 +9,15 @@ import sys
class PySnmpError(Exception):
- def __init__(self, message):
+ def __init__(self, *args):
+ msg = args and str(args[0]) or ''
+
self.cause = sys.exc_info()
- Exception.__init__(self, '%s, caused by %s: %s' % (message, self.cause[0], self.cause[1]))
+
+ if self.cause[0]:
+ msg += 'caused by %s: %s' % (self.cause[0], self.cause[1])
+
+ if msg:
+ args = (msg,) + args[1:]
+
+ Exception.__init__(self, *args)