Check user access before opening a file

I am using to open an excel document from the companies network drive, but for some users when i click the button that has been scripted to open the file, nothing happens. we determined that the reason for the file not opening was because some of the users do not have permission to the file, but there is no error message or console output to indicate that there is a problem.

is there a way to determine if the user has access to the file or not and notify the user if they do not possess the correct permissions to open the file?

Since it’s passed off to Windows to try and open, it really should be Windows telling you about permissions problems. That being said:

from java.nio.file import Files, Paths

filepath = '/the/path/to/the/file'

if Files.isReadable(Paths.get(filepath)):
  system.gui.errorBox("File either does not exist or you do not have sufficient privileges", "Access denied")