Content deleted Content added
clarify |
intro |
||
Line 1:
In [[Programming language|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 be used in conjunction with exception handling. ''Error codes'' are not to be confused with
In programming languages without structured exception handling (e.g. in the [[C programming language]]), ''error codes'' are often stored in [[global variable]]s with names like ''errno'' . Error codes are typically identified by number, each indicating a specific error condition. In an application that uses error codes, each function typically defines one ''return code'' to indicate a general failure. Upon receipt of that general failure return code, the programmer can check the value stored in the global error code to determine the condition that caused the function to fail. For example, to indicate that an attempt to open a file failed, a function may set the global error code to indicate the cause of the failure and return an invalid file handle. The following sample shows how the error code can be used to explain the cause of the error:
|