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

How to handle java.io.Exception in python notebook

StuartParker188
New Contributor III

I'm attempting to mount a volume using dbutils.fs.mount in a python workbook

in the exception handling for this statement, I have found an exception that doesn't get caught using the standard try/except handling

for example, if passing through a container name that does not exist I get the following exception - but it is not caught

ExecutionError: An error occurred while calling o390.mount.

: java.io.FileNotFoundException: /: No such file or directory.

Is there an approach to catch a java.io.Exception within a python notebook?

5 REPLIES 5

Debayan
Esteemed Contributor III
Esteemed Contributor III

Hi @Stuart Parker​ , Could you please check in the Data/DBFS page if the file is there (or via dbutils.fs.ls, https://docs.databricks.com/dev-tools/databricks-utils.html)?

Hi @Debayan Mukherjee​ 

The issue is not a file one. In the workbook that mounted the container, the container name was mis-typed. Despite the mount command being wrapped in a try..catch.. block, it was not caught and this error bubbled up and threw an exception that stopped the workbook.

My question relates to how to handle future events like this where standard pythonic exception handling doesn't work

Hubert-Dudek
Esteemed Contributor III

If except Exception as error: is not working, you can check first if container name exists as resource

Thanks - you are correct - however I am attempting to determine if it is possible to catch the Java error that is bubbling up within the pyspark environment

Anonymous
Not applicable

Hi @Stuart Parker​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

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.