August 1999
Intermediate to advanced
1488 pages
72h 53m
English
file.error()
The error() method of the File object returns the operating system error code when an error occurs opening a file. This method returns 0 if there is no error, and –1 if the file you invoke the method on is not open.
Listing 8.75 opens a file for reading. If there was a problem during this operation, the error is written to the user's page.
<SERVER> // Open a log file var myLog = new File("/data/logs/today.log"); // Open the log file for reading myLog.open("r"); if (myLog.error() == 0) { // Perform actions on file }else{ // Write out the error write('Error: ' + myLog.error()); // Clear the error ... |
Read now
Unlock full access