The Log-and-Raise Anti-Pattern
By Eric
—
—
6 minute read
In its simplest form, the log-and-raise pattern looks like this:
def my_function() -> None:
try:
do_something()
except Exception:
logger.exception("My function failed!")
raise
What's wrong with that? Even the official Python documentation says:
The most common pattern for handling Exception is to print or log the exception and then re-raise …






