File.clearError()
NES2+Syntax
file.clearError()
Description
The clearError() method of the File object clears the file error status and the value returned by the eof() method.
Example
Listing 8.72 opens a file for reading. If the operation returned an error, the error is written to the page. If there was an error, it is cleared after writing it.
Listing 8.72 Using the clearError() Method to Clear File Errors
<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 myLog.clearError() } // Close the file myLog.close(); </SERVER> |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.