Project

General

Profile

« Previous | Next » 

Revision 974

exc.py: print_ex(): Declare emph param as a keywork param instead of popping it from **format

View differences:

lib/exc.py
13 13

  
14 14
def repl_msg(e, **repls): e.args = (str(e) % repls,)
15 15

  
16
def e_ct_exit_status(e_ct): return min(e_ct, 255)
17

  
16 18
class ExceptionWithCause(Exception):
17 19
    def __init__(self, msg, cause=None):
18 20
        Exception.__init__(self, msg)
......
34 36
    def __init__(self):
35 37
        self.e_ct = 0
36 38
        def at_exit():
37
            if self.e_ct > 0:
38
                raise SystemExit('Encountered '+str(self.e_ct)+' error(s)')
39
            sys.stderr.write(self.msg()+'\n')
40
            if self.e_ct > 0: raise SystemExit(e_ct_exit_status(self.e_ct))
39 41
        atexit.register(at_exit)
40 42
    
43
    def msg(self): return 'Encountered '+str(self.e_ct)+' error(s)'
44
    
41 45
    def track(self, e, **format):
42 46
        self.e_ct += 1
43 47
        print_ex(e, **format)

Also available in: Unified diff