Am new to databricks . I have a notebook that has multiple commands . I want to capture the specific error message that is thrown when any of the commands fail. basically I would want to customize the error message in order to be able to identify which command of the notebook failed or caused the failure . In my Notebook each command performs a specific task and I want to know which task failed . How or what should I include to capture the error details ?
Currently we are just setting a generic error message when the notebook activity failed , but we are trying to find a mechanism that would give us more info on which command in the notebook failed that caused the notebook activity to fail
You can use
tracebackmodule to store the error as suggested by @John Gordon in comments.Use below code and keep your code in try block.
Example:
This will give the exact information about the error and error line in your code.
You can also store your error in a file with
traceback.print_exc(file=fileObject).