Topic: continuation
Topic: default exception handler
Topic: exception handling by recovery block or rescue clause
Topic: exception handling by termination
Topic: failure returning functions and expressions
Topic: object-defined exception handling
| |
Summary
Since an exception is part of a procedure's abstraction, it should be handled by its caller. Liskov argues that only the immediate caller should be involved, otherwise the handler is implementation dependent.
Typically, the handler is statically attached to the expression, statement block, or call. If a handler does not exist for a particular exception, the exception is passed to a higher level. (cbb 11/92)
Subtopic: exception safety
Quote: exception safety -- exceptions are synchronous, it is safe to destroy, swap does not throw [»dewhSC_2005]
| Quote: C++ containers are exception-safe generic components; no cost for normal operation, exceptions for cost comparable to a function call [»abraD4_1998]
| Quote: exception-neutrality for generic components; exceptions thrown by type parameters are passed unchanged to the component's caller [»abraD4_1998]
| Quote: exception-safety provides the basic-guarantee and may provide strong or no-throw guarantees; destructors do not throw exceptions [»abraD4_1998]
| Quote: basic-guarantee of exception-safety -- invariants preserved and no resource leaks
| Quote: strong-guarantee of exception-safety -- either an operation completes successfully or an exception occurs without changing the program state
| Quote: examine non-const operations for exception-safety; e.g., strong guarantee for set::insert, and no-throw guarantee for an iterator's copy constructor [»abraD4_1998]
Quote: automated test of exception-safety; ThisCanThrow() throws an exception when a global counter becomes zero; rerun with increasing values of the counter; operations must be exception-neutral [»abraD4_1998]
| Quote: analyzing exceptions for correctness is difficult [»cargT11_1994]
| | Subtopic: exceptions vs. return values
Quote: exceptions promote API consistency; designed for failure reporting and nothing else; while return values have many uses, e.g., Win32 API [»cwalK_2006]
| Quote: error codes are often ignored; exceptions are impossible to ignore, improving robustness [»cwalK_2006]
| Quote: exceptions carry rich information describing the cause of the failure [»cwalK_2006]
| Quote: exceptions promote instrumentation; for example, debuggers can break when an exception is thrown [»cwalK_2006]
| Subtopic: caller handles errors
Quote: an exception handler catches the event and either raises an exception or handles the event
| Quote: the author of a library can detect run-time errors but does not know what to do about them; use throw and catch [»stroB_1991]
| Quote: throw and catch separates error handling code from ordinary code; error handling is more regular than with error values or error call-backs
| Quote: a faulting execution raises an event that is propagated to an exception handler in a source execution; may differ [»buhrPA9_2000]
| Quote: lower levels can't use knowledge about higher levels; but undesired events need higher level information to determine the appropriate action [»parnDL10_1976b]
| QuoteRef: parnDL5_1972 ;;331 errors should be handled by user of module not module itself
| QuoteRef: goodJB12_1975 ;;688 can pass exceptions from local to global context
| Subtopic: try..catch -- syntactic
Quote: the most natural way to describe exceptions is to throw objects and catch classes; a copy of the object thrown is passed to the handler [»koenA_1990]
| Quote: throw and catch separates error handling code from ordinary code; error handling is more regular than with error values or error call-backs
| Quote: a throw-expression is a return statement that uses the value's class to select the caller [»koenA_1990]
| Quote: handle exceptions with clauses associated with individual statements; gives example [»shawM9_1978]
| Quote: attaches exception handlers to statements but not expressions; gives example [»liskBH11_1979]
| Quote: Modula-3 handles exceptions with TRY-EXCEPT-ELSE; an exception may return a value [»cardL_1991]
| QuoteRef: goodJB12_1975 ;;687 exception handler reach is syntactic unit it is attached to unless sub units handle the same exception
| QuoteRef: goodJB12_1975 ;;684 operations raise an exception which are handled by their invoker
| QuoteRef: goodJB12_1975 ;;686 Hoare: Q1 otherwise Q2 i.e. Q2 local exception handler for Q1
| QuoteRef: goodJB12_1975 ;;686 exception handlers are default or invoker defined
| QuoteRef: goodJB12_1975 ;;686 static association of handler with activation point eg (a+b) [overflow:...] attached to syntactic unit
| QuoteRef: goodJB12_1975 ;;687 exception handlers may include several exceptions and be attached to expressions or statements
| Subtopic: try-parse
Quote: the try-parse pattern reports failure instead of an exception; avoids performance problem for a common scenario [»cwalK_2006]
| Subtopic: finally clause
Quote: TRY S_1 FINALLY S_2 executes S_2 even if S_1 throws an exception [»cardL_1991]
| Subtopic: stack unwinding
Quote: CLR uses Ramsey and Jones' two-pass runtime-stack unwinding exception handlers; first, find the handler, then cleanup stack, etc.; first, cross-language exception handler [»hamiJ2_2003]
| Quote: resource acquisition is initialization. Resources, like objects, are released in the reverse order of their acquisition; works well with exception handling [»stroB_1991]
| Quote: an object is not constructed until its constructor has completed; an exception calls a destructor only for constructed objects
| Quote: when signal an exception, search handler table for candidate with smallest scope [»liskBH11_1979]
| Quote: resource acquisition is initialization: resources released in reverse order of acquisition, and exceptions release allocated resources [»stroB_1994]
| Quote: exception handling by stack cutting w/o restore, table-driven stack unwinding, stack unwinding via code, and continuation-passing via code [»ramsN6_2000]
| Quote: efficient implementation of Modula-3 exceptions using a stack of exception handlers [»ramsN6_2000]
| QuoteRef: reynJC_1965 ;;427 failure of a generator is propagated up until a conditional jump is reached
| Subtopic: exception handling by continuation
Quote: model an exception handler as a C-- continuation; like a label with parameters; a non-local exit via 'cut to' [»ramsN6_2000]
| Quote: C-- calls specify exception handling by abort, cut, unwind, or continuation within same procedure [»ramsN6_2000]
| Quote: C-- exception handling adds explicit flow edges from the call site to a continuation or exit node [»ramsN6_2000]
| Quote: use continuations to handle side effects, abnormal exits, and gotos [»tennRD8_1976, OK]
| Quote: an escape expression is like jumping to a label while passing an argument; applies a higher-order continuation [»reynJC8_1972]
| Subtopic: implementing exception handlers
Quote: CLR exception handlers may be typed (catch on type match), filtered (catch on true evaluation), termination (always called on exception cleanup); late binding
| Quote: implement exception handling with a table of code address ranges, destructors, and exception handlers [»stroB_1994]
| Quote: an exception handler may goto a nonlocal label, terminate intervening blocks, retry, or resume
| Quote: an implementation of Modula-3 exceptions should not increase the cost of procedure calls; the specification suggests a minimum ratio of a 1000 to 1 [»cardL_1991]
| Quote: Piccola uses its dynamic namespace to implement exception handling [»acheF9_2000]
| Subtopic: cost of exception
Quote: the cost of an exception is hard to predict; depends on depth of stack and number of objects; not suitable for hard real time [»stroB12_2004]
|
Related Topics
Topic: continuation (16 items)
Topic: default exception handler (3 items)
Topic: exception handling by recovery block or rescue clause (22 items)
Topic: exception handling by termination (16 items)
Topic: failure returning functions and expressions (24 items)
Topic: object-defined exception handling (10 items)
|