comparison piecrust/chefutil.py @ 272:a561fbad0b7f

logging: If an error doesn't have a message, print its type.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 01 Mar 2015 09:07:02 -0800
parents 133845647083
children e7b865f8f335
comparison
equal deleted inserted replaced
271:12657039c436 272:a561fbad0b7f
12 12
13 13
14 def log_friendly_exception(logger, ex): 14 def log_friendly_exception(logger, ex):
15 indent = '' 15 indent = ''
16 while ex: 16 while ex:
17 logger.error('%s%s' % (indent, str(ex))) 17 ex_msg = str(ex)
18 if not ex_msg:
19 ex_msg = '%s exception was thrown' % type(ex).__name__
20 logger.error('%s%s' % (indent, ex_msg))
18 indent += ' ' 21 indent += ' '
19 ex = ex.__cause__ 22 ex = ex.__cause__
20 23
21 24
22 def print_help_item(s, title, description, margin=4, align=25): 25 def print_help_item(s, title, description, margin=4, align=25):