The file module has functions get and clear a file’s error status that are almost exact equivalents to POSIX API functions; the primary difference is the advantage of valuable return error codes to the application.
For more information about this functionality, see Diagnosing a File Error.