mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Improve output when interrupted (^C)
This commit is contained in:
parent
b3bfecde39
commit
f21316ebe8
2 changed files with 31 additions and 6 deletions
|
|
@ -44,9 +44,11 @@ def _log_and_exit(msg, exc, formatted):
|
|||
def error_handler():
|
||||
try:
|
||||
yield
|
||||
except FatalError as e:
|
||||
_log_and_exit('An error has occurred', e, traceback.format_exc())
|
||||
except Exception as e:
|
||||
_log_and_exit(
|
||||
'An unexpected error has occurred', e, traceback.format_exc(),
|
||||
)
|
||||
except (Exception, KeyboardInterrupt) as e:
|
||||
if isinstance(e, FatalError):
|
||||
msg = 'An error has occurred'
|
||||
elif isinstance(e, KeyboardInterrupt):
|
||||
msg = 'Interrupted (^C)'
|
||||
else:
|
||||
msg = 'An unexpected error has occurred'
|
||||
_log_and_exit(msg, e, traceback.format_exc())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue