cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Error handling/exception handling in NOtebook

KuldeepChitraka
New Contributor III

What is a common practice to to write notebook which includes error handling/exception handling.

Is there any example which depicts how notebook should be written to include error handling etc.

4 REPLIES 4

Ajay-Pandey
Esteemed Contributor III

Hi @Kuldeep Chitrakar​ you can use try and catch to handle the exception

ramravi
Contributor II

 it's just a simple try except  code, something like this:

results = {}
 
were_errors = False
 
for script_name in ['script1', 'script2', 'script3']:
 
  try:    
 
    retValue = dbutils.notebook.run(script_name)
 
    results[script_name] = retValue
 
  except Exception as e:
 
    results[script_name] = "Error: {e}"
 
    were_errors = True
 
 
 
if were_errors:
 
  log failure # you can use data from results variable
 
else:
 
  log success

Aviral-Bhardwaj
Esteemed Contributor III

use try catch

Meghala
Valued Contributor II

runtime looks for handlers (try-catch) that are registered to handle such exceptions

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.