Customizing `runMain` Exit Handling for Logging Errors in a CLI

Whats the best way to customise the runMain exit handling to log expected errors with just the contained message and unexpected errors with the default pretty printed error with stack trace?

I'm writing a CLI, I return a CLIError whenever an expected error occurs, other (tracked and tagged) errors I want to allow to bubble out and trigger the default exit code and logger (with stack trace)

I've tried to customise runMain via the teardown option, inside I'm catching the CliErrors and logging these. Works fine. But I don't know how to trigger the default teardown and logger for everything else
Was this page helpful?