Revision 279
Added by Aaron Marcuse-Kubitza about 13 years ago
ex.py | ||
---|---|---|
1 | 1 |
# Exception handling |
2 | 2 |
|
3 |
def add_msg(ex, msg): ex.args = (str(ex).rstrip()+'\n'+msg,)
|
|
3 |
def add_msg(e, msg): e.args = (str(e).rstrip()+'\n'+msg,)
|
|
4 | 4 |
|
5 |
def repl_msg(e, repls): e.args = (str(e) % repls,) |
|
6 |
|
|
5 | 7 |
class ExceptionWithCause(Exception): |
6 | 8 |
def __init__(self, msg, cause=None): |
7 | 9 |
Exception.__init__(self, msg) |
Also available in: Unified diff
ex.py: Added repl_msg() to format a message with the % operator