Graceful exit

From Wiki @ Karl Jones dot com
Jump to: navigation, search

In computer programming, graceful exit (or graceful handling) is the principle that a computer program should detect serious error conditions and "exit gracefully" in a controlled manner.

Description

Often the program prints a descriptive error message to a terminal or log as part of the graceful exit.

Usually, code for a graceful exit exists when the alternative—allowing the error to go undetected and unhandled—would produce spurious errors or later anomalous behavior that would be more difficult for the programmer to debug. The code associated with a graceful exit may also take additional steps, such as closing files, to ensure that the program leaves data in a consistent, recoverable state.

Graceful exits are not always desired. In many cases, an outright crash can give the software developer the opportunity to attach a debugger or collect important information, such as a core dump or stack trace, to diagnose the root cause of the error.

Exception handling

In a language that supports exception handling, a graceful exit may be the final step in the handling of an exception.

In other languages graceful exits can be implemented with additional statements at the locations of possible errors.

See also

External links