Project

General

Profile

« Previous | Next » 

Revision 788

exc.py: Added str_() to convert an Exception to a string. Use str_() in print_ex().

View differences:

lib/exc.py
15 15
class ExceptionWithCause(Exception):
16 16
    def __init__(self, msg, cause=None):
17 17
        Exception.__init__(self, msg)
18
        if cause != None: add_msg(self, 'cause: '+str(cause))
18
        if cause != None: add_msg(self, 'cause: '+str_(cause))
19 19

  
20
def print_ex(e, with_name=True):
20
def str_(e, with_name=True):
21 21
    msg = strings.ensure_newl(str(e))
22 22
    if with_name: msg = util.type_name(e)+': '+msg
23
    sys.stderr.write('! '+msg)
23
    return msg
24 24

  
25
def print_ex(e, **format): sys.stderr.write('! '+str_(e, **format))
26

  
25 27
class ExTracker:
26 28
    def __init__(self):
27 29
        self.e_ct = 0

Also available in: Unified diff