Forum Discussion
How do you throw an error from a Notebook so a Data Factory pipeline knows to stop running?
- 2 years ago
Thanks for the reply, frithjof_v. The challenge there is I'd then need to add logic in the pipeline to evaluate whether or not the exit value output indicates an error.
The solution I found (which I found somewhere on the internet that I don't recall) is to use raise Exception("Error message here"). Here's a modified version of the code block; the vars are just fake examples of operations I am performing:
if var == None: raise Exception("No match found.") else: var2 = varThis sends the exception back as an error to the pipeline so the Notebook activity actually fails, which is handy.
I think you can use exit value in Notebook.
And then use the Notebook exit value as input for an IF Condition activity in your data pipeline.
- arpost2 years agoPost Prodigy
Thanks for the reply, frithjof_v. The challenge there is I'd then need to add logic in the pipeline to evaluate whether or not the exit value output indicates an error.
The solution I found (which I found somewhere on the internet that I don't recall) is to use raise Exception("Error message here"). Here's a modified version of the code block; the vars are just fake examples of operations I am performing:
if var == None: raise Exception("No match found.") else: var2 = varThis sends the exception back as an error to the pipeline so the Notebook activity actually fails, which is handy.
- frithjof_v2 years agoCommunity Champion
Nice, thanks for sharing!