Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
arpost
Kudo Collector
Kudo Collector

How do you throw an error from a Notebook so a Data Factory pipeline knows to stop running?

Greetings, all. I am wanting a notebook to throw an error if a condition isn't met, and I want that error to show in a Data Factory pipeline that is triggering the notebook. How can I do this?

1 ACCEPTED SOLUTION

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 = var

 

 

This sends the exception back as an error to the pipeline so the Notebook activity actually fails, which is handy.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @arpost ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
frithjof_v
Community Champion
Community Champion

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.

 

https://community.fabric.microsoft.com/t5/Data-Pipelines/Referencing-notebook-exit-value-as-a-variab...

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 = var

 

 

This sends the exception back as an error to the pipeline so the Notebook activity actually fails, which is handy.

Nice, thanks for sharing!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors