Project

General

Profile

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 279 aaronmk
def repl_msg(e, repls): e.args = (str(e) % repls,)
6
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))