词条 | Graceful exit |
释义 |
A graceful exit[1] (or graceful handling) is a simple programming idiom{{citation needed|date=May 2016}} wherein a program detects a serious error condition and "exits gracefully" in a controlled manner as a result. 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. In a language that supports formal 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. The phrase "graceful exit" has also been generalized to refer to letting go from a job or relationship in life that has ended.[2][3] In PerlIn the Perl programming language, graceful exits are generally implemented via the die operator. For example, the code for opening a file often reads like the following: If the attempt to open the file . In JavaIn the Java programming language, the try...catch block is used often to catch exceptions. All potentially dangerous code is placed inside the block and, if an exception occurred, is stopped, or caught. In CIn C one can use the error(3) function, provided in GNU by the GNU C Library. If the first parameter is non-zero this function will exit from the parent process and return that parameter. See also
References1. ^{{cite web |url=http://encyclopedia2.thefreedictionary.com/graceful+exit |title=graceful exit |publisher=The Free Dictionary |accessdate=September 25, 2016}} {{DEFAULTSORT:Graceful Exit}}{{Compu-prog-stub}}2. ^{{cite web |url=https://www.goodreads.com/quotes/61373-there-s-a-trick-to-the-graceful-exit-it-begins-with |title=Quote by Ellen Goodman: "There's a trick to the 'graceful exit.' It begi..." |author=Ellen Goodman |website=Goodreads |quote=There's a trick to the 'graceful exit.' It begins with the vision to recognize when a job, a life stage, or a relationship is over — and let it go. It means leaving what’s over without denying its validity or its past importance to our lives. It involves a sense of future, a belief that every exit line is an entry, that we are moving up, rather than out.}} 3. ^{{cite web |url=https://www.wsj.com/articles/leave-your-job-gracefully-1439924165 |title=How to Leave Your Job Gracefully |author=Sue Shellenbarger |date=August 18, 2015 |publisher=The Wall Street Journal |quote=A graceful exit can burnish an employee’s reputation and shore up valuable relationships. A bad one can do serious damage to both.}} 2 : Computer programming folklore|Control flow |
随便看 |
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。