root/lib/ex.py @ 287
1 | 11 | aaronmk | # Exception handling
|
---|---|---|---|
2 | |||
3 | 279 | aaronmk | def add_msg(e, msg): e.args = (str(e).rstrip()+'\n'+msg,) |
4 | 13 | aaronmk | |
5 | 286 | aaronmk | def repl_msg(e, **repls): e.args = (str(e) % repls,) |
6 | 279 | aaronmk | |
7 | 13 | aaronmk | class ExceptionWithCause(Exception): |
8 | def __init__(self, msg, cause=None): |
||
9 | Exception.__init__(self, msg) |
||
10 | if cause != None: add_msg(self, 'cause: '+str(cause)) |