
We’ve been having some fun with Click and Python decorators at work.
We had a situation where we wanted to
- transform any
Exception
to aclick.ClickException
, so they would be rendered nicely, and - catch one particular exception, and retry the function that raised it with a different parameter value as a fallback.
We got the first behaviour quickly into a decorator. We then realised that the second could also be done nicely with a decorator, too.
Continue reading