Is there a way to handle exceptions automatically with Python Click?
01:15 25 Aug 2017

Click's exception handling documentation mentions that certain kinds of exceptions such as Abort, EOFError and KeyboardInterrupt are automatically handled gracefully by the framework.

For the application I'm writing, there are a lot of points from which exceptions could be generated. Terminating the application is the right step, but printing the stack trace isn't. I could always manually do this:

@cli.command()
def somecommand:
  try:
    # ...
  except Exception as e:
    click.echo(e)

However, is there a way to have Click handle all exceptions automatically?

python python-3.x exception python-click