cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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

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!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group