Handling FileNotFoundException

Hi, I am trying to use a try/except block. It looks like there was a thread on this awhile back, but the user wasn’t importing the java module. I just wanted to make sure I’m not missing anything.


import java

dataSet =  event.source.parent.getComponent('Table').data

	filePath = system.dataset.exportExcel("totals.xls", 1, dataSet)

except java.io.FileNotFoundException, e:
	system.gui.errorBox('File is currently open.  Please close file and export again.')
if filePath is not None:

Change line 1 to

from java.io import FileNotFoundException

And the except line to

except FileNotFoundException,e:

Importing classes is slooooww. Only import what you need.


Thanks for the response. I added the changes to the code, however I am still not catching the error. I should have noted in my original post that exception is thrown if I have the file open, and I export the dataset a second time. I dug up the old thread from 2010, here is a link: