Project

General

Profile

1
# Exception handling
2

    
3
def add_msg(e, msg): e.args = (str(e).rstrip()+'\n'+msg,)
4

    
5
def repl_msg(e, **repls): e.args = (str(e) % repls,)
6

    
7
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))
(3-3/11)