Error code
Encyclopedia
In computer programming
, error codes are enumerated messages that correspond to faults in a specific software application. They are typically used to identify faulty hardware
, software, or incorrect user input in programming languages that lack exception handling
, although they are sometimes also used in conjunction with exception handling. Error codes are not to be confused with return codes, although both are commonly used together in error handling. Some of the most severe error codes visible to users are the "Blue Screen of Death" codes provided by the Microsoft Windows operating systems
.
programming languages replace them with exceptions
. Exceptions have the advantage of being handled with explicit blocks of code, separate from the rest of the code. While it is considered poor practice in methodologies that use error codes and return codes to indicate failure, programmers often neglect to check return values for error conditions. That negligence can cause undesirable effects, as ignored error conditions often cause more severe 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 from the normal logic makes programs easier to write and understand, since one block of error handling code can service errors from any number of function calls. Exception handling also makes the code more readable than implementations with error codes, since exception handling does not disrupt the flow of the code with frequent checks for error conditions.
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
, error codes are enumerated messages that correspond to faults in a specific software application. They are typically used to identify faulty hardware
Hardware
Hardware is a general term for equipment such as keys, locks, hinges, latches, handles, wire, chains, plumbing supplies, tools, utensils, cutlery and machine parts. Household hardware is typically sold in hardware stores....
, software, or incorrect user input in programming languages that lack exception handling
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....
, although they are sometimes also used in conjunction with exception handling. Error codes are not to be confused with return codes, although both are commonly used together in error handling. Some of the most severe error codes visible to users are the "Blue Screen of Death" codes provided by the Microsoft Windows operating systems
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
.
Error codes and exception handling
Error codes are slowly disappearing from the programmer's environment as modern object-orientedObject-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
programming languages replace them with exceptions
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....
. Exceptions have the advantage of being handled with explicit blocks of code, separate from the rest of the code. While it is considered poor practice in methodologies that use error codes and return codes to indicate failure, programmers often neglect to check return values for error conditions. That negligence can cause undesirable effects, as ignored error conditions often cause more severe 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 from the normal logic makes programs easier to write and understand, since one block of error handling code can service errors from any number of function calls. Exception handling also makes the code more readable than implementations with error codes, since exception handling does not disrupt the flow of the code with frequent checks for error conditions.
See also
- Abort (computing)Abort (computing)In a computer or data transmission system, to abort means to terminate, usually in a controlled manner, a processing activity because it is impossible or undesirable for the activity to proceed. Such an action may be accompanied by diagnostic information on the aborted process.In addition to being...
- Aspect-oriented programmingAspect-oriented programmingIn computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...
- Exit statusExit statusThe exit status or return code of a process in computer programming is a small number passed from a child process to a parent process when it has finished executing a specific procedure or delegated task...
- FailureFailureFailure refers to the state or condition of not meeting a desirable or intended objective, and may be viewed as the opposite of success. Product failure ranges from failure to sell the product to fracture of the product, in the worst cases leading to personal injury, the province of forensic...
- Static code analysisStatic code analysisStatic program analysis is the analysis of computer software that is performed without actually executing programs built from that software In most cases the analysis is performed on some version of the source code and in the other cases some form of the object code...