An OS handles errors through a system of error reporting and handling. When an error occurs, the OS logs it, often displaying a message to the user. It then attempts to recover from the error, if possible, or it may halt the system to prevent further damage. Some OSs also have built-in tools for diagnosing and fixing common problems.