I try to check if the path exists in Databricks using Python:
try:
dirs = dbutils.fs.ls ("/my/path")
pass
except IOError:
print("The path does not exist")
If the path does not exist, I expect that the except
statement executes.
However, instead of except
statement, the try
statement fails with the error:
java.io.FileNotFoundException: GET ...
ErrorMessage=The specified path does not exist.
How to properly catch FileNotFoundException
?