filipniziol
Esteemed Contributor

If you want to fail the notebook then instead of dbutils.notebook.exit simply raise an exception:

if existing_failure > 0:
raise Exception("Exiting due to a previously logged failure.").