Skip to content

Commit

Permalink
cleanup exception printing a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mayfield committed Feb 18, 2023
1 parent d55bb45 commit d37296a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shellish/command/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def run_wrap(self, args):
except (SystemExit, Exception) as e:
self.postrun(args, exc=e)
self.fire_event('postrun', args, exc=e)
raise e
raise
else:
self.postrun(args, result=result)
self.fire_event('postrun', args, result=result)
Expand Down
4 changes: 2 additions & 2 deletions shellish/rendering/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def format_exception(exc, indent=0, pad=' '):
yield '\n%s%s\n' % (padding, from_msg)
yield '%s<b><u>Traceback (most recent call last)</u></b>' % padding
tblist = traceback.extract_tb(exc.__traceback__)
tbdepth = len(tblist)
tbdepth = 1
for x in tblist:
depth = '%d.' % tbdepth
yield '%s<dim>%-3s</dim> <cyan>File</cyan> "<blue>%s</blue>", ' \
'line <u>%d</u>, in <b>%s</b>' % (padding, depth, x.filename,
x.lineno, x.name)
yield '%s %s' % (padding, x.line)
tbdepth -= 1
tbdepth += 1
yield '%s<b><red>%s</red>: %s</b>' % (padding, type(exc).__name__, exc)
return indent + 1

Expand Down
2 changes: 1 addition & 1 deletion shellish/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def execute(self, command, args):
result = command.run_wrap(args)
except BaseException as e:
self.fire_event('postcmd', command, args, exc=e)
raise e
raise
else:
self.fire_event('postcmd', command, args, result=result)
return result
Expand Down

0 comments on commit d37296a

Please sign in to comment.