In
computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as ana ...
, a return code or an error code is a numeric or
alphanumeric
Alphanumericals or alphanumeric characters are a combination of alphabetical and numerical characters. More specifically, they are the collection of Latin letters and Arabic digits. An alphanumeric code is an identifier made of alphanumeric ch ...
code that is used to determine the nature of an error and why it occurred. They are also commonly found in consumer electronics and devices when they attempt to do something they cannot do (e.g.,
dividing by zero) or fail to do and they can be passed off to
error handlers that determine what action to take.
In
vehicles
A vehicle (from la, vehiculum) is a machine that transports people or cargo. Vehicles include wagons, bicycles, motor vehicles (motorcycles, cars, trucks, buses, mobility scooters for disabled people), railed vehicles (trains, trams), wate ...
, error codes are five-digit codes that pinpoint a particular car fault. Car owners can make use of an
on-board diagnostics
On-board diagnostics (OBD) is a term referring to a vehicle's self-diagnostic and reporting capability. OBD systems give the vehicle owner or repair technician access to the status of the various vehicle sub-systems. The amount of diagnostic inf ...
scanner to identify a trouble code. The five-digit Diagnostic trouble code typically consists of one letter and four numbers (e.g
P0123
In consumer products
![Error-code-e74](https://upload.wikimedia.org/wikipedia/commons/1/18/Error-code-e74.jpg)
Error codes can also be used to specify an error, to simplify research into the cause and how to fix it. This is commonly used in consumer products when something goes wrong, such as the cause of the
Blue Screen of Death, to make it easier to pinpoint the exact problem the product is having.
There is no definitive form of an error code. Some styles use decimal or
hexadecimal
In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, hexa ...
numbers, others use alphanumeric codes and some use a phrase describing the error.
In computing
Error codes in computers can be passed to the system itself, to judge how to respond to the error. Often error codes come synonymous with an exit code or a return value. The system may also choose to pass the error code to its user(s). The
Blue screen of death is an example of how a popular
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
communicates error codes to the user.
In networking software
Network protocol
A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any kind of variation of a physical quantity. The protocol defines the rules, syntax, semantics and synchroniza ...
s typically support returning status codes. In the
TCP/IP stack
The Internet protocol suite, commonly known as TCP/IP, is a framework for organizing the set of communication protocols used in the Internet and similar computer networks according to functional criteria. The foundational protocols in the suit ...
, it's a common feature of higher level protocols. For example:
*
List of HTTP status codes
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a client's request made to the server. It includes codes from IETF Request for Comments (RFCs), other specifications, ...
*
List of FTP server return codes
FTP server return codes always have three digits, and each digit has a special meaning.RFC 959 The first digit denotes whether the response is good, bad or incomplete:
The second digit is a grouping digit and encodes the following information:
...
*
Simple Mail Transfer Protocol#Protocol overview
In Automobiles
Error codes
in automobiles indicate to a driver or car mechanic what is wrong with a vehicle before repair(s) are initiated. A car is liable to display as many fault codes as possible on the OBD-II scanner, it all depends on the state of the engine system.
Error codes and exception handling
Error codes are passed to
exception handling
In computing and computer programming, exception handling is the process of responding to the occurrence of ''exceptions'' – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an ...
in programming languages that support it. These are passed to log files and the parent process to determine what action to take.
See also
*
errno.h
errno.h is a header file in the standard library of the C programming language. It defines macros for reporting and retrieving error conditions using the symbol errno (short for "error number").International Standard for Programming Language C ...
, a header file in C that defines macros for reporting errors
*
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 or in conjunction with an error. Such an action ma ...
*
Aspect-oriented programming
In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding behavior to existing code (an advice) ''without'' modifying t ...
*
Failure
Failure is the state or condition of not meeting a desirable or intended objective (goal), objective, and may be viewed as the opposite of Success (concept), success. The criteria for failure depends on context, and may be relative to a parti ...
*
Exit status
The exit status of a process in computer programming is a small number passed from a child process (or callee) to a parent process (or caller) when it has finished executing a specific procedure or delegated task. In DOS, this may be referred t ...
*
Static code analysis
In computer science, static program analysis (or static analysis) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs during their execution.
The term i ...
References
{{Reflist
External links
Lists of Linux errno values, both numeric and symbolicMicrosoft system error codesMicrosoft Device Manager error codes
Software