In Programming language error codes are numbered messages that correspond to faults in a specific software application, which can be caused by faulty hardware, software, or incorrect user input. Error codes are not to be confused with return codes though the latter are commonly used in error handling. Some of the most common error codes visible to users are the "Blue Screen of Death" codes provided by the Microsoft Windows operating system.
Error codes are often process global variables, such as errno in C. A return code from a function will indicate an error condition (such as -1 bytes read from a file) and the programmer can then check the value of errno against a list of possible errors to determine why the function call failed.
Error codes are slowly disappearing from the programmer's environment as modern object oriented computer languages replace them with exceptions. Exceptions have the advantage of being handled with explict blocks of code, separate from the rest of the code. While it is considered poor practice, programmers often fail to check return values for error conditions, and this can cause undesirable effects as ignored error codes cause additional problems later in the program. Exceptions are implemented in such a way as to separate the error handling code from the rest of the code. Separating the error handling code makes programs easier to write, since one block of error handling code can service errors from any number of function calls. Exception handling also makes the code more readable, since is does not disrupt the flow of the code with frequent checks for error conditions.