Project

General

Profile

« Previous | Next » 

Revision 2308

exc.py: str_(): Added first_line_only param to return just the first line

View differences:

lib/exc.py
50 50
            msg += ': '+str_(cause)
51 51
        Exception.__init__(self, msg)
52 52

  
53
def str_(e):
54
    return u''.join(traceback.format_exception_only(type(e), e)).rstrip()
53
def str_(e, first_line_only=False):
54
    msg = u''.join(traceback.format_exception_only(type(e), e)).rstrip()
55
    if first_line_only: msg = msg.partition('\n')[0]
56
    return msg
55 57

  
56 58
def print_ex(e, emph=True, detail=True, plain=False):
57 59
    if plain:

Also available in: Unified diff