diff options
Diffstat (limited to 'pysnmp/error.py')
-rw-r--r-- | pysnmp/error.py | 13 |
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) |