This function is supposed to catch exceptions in the main execution. If there is an exception it should print out the error with log.error(traceback.print_exc())
and clean up with exit_main()
.
def main():
try:
exec_app()
except KeyboardInterrupt:
log.error('Error: Backup aborted by user.')
exit_main()
except Exception:
log.error('Error: An Exception was thrown.')
log.error("-" * 60)
log.error(traceback.print_exc())
log.error("-" * 60)
exit_main()
Unfortunately log.error(traceback.print_exc())
does only return None
if there is an exception. How can I make traceback print the full error report in this case?
PS: I use python 3.4.
traceback.print_exc()
? it would logs all exceptions exceptKeyboardInterrupt
– Godavariexec_app()
. – Hardily