I have developed a azure databricks notebook where data will be copied from landing zone to STG delta table, used Try and except blocks in the code to catch the errors, if their is an error the except block will catch the error message. In the except block i have written the sql query to update the values in audit table by using spark.sql. My issue is when try block got succeeded some how the sql query in except block is executing and updating the audit table for the error description column with the output of the succeeded Try block . Please suggest me in this regard.