Group: exception handling

topics > computer science > Group: programming

default exception handler
exceptions and undesired events
exceptions from invalid input
exception handling by recovery block or rescue clause
exception handling by termination
exception handling by unique value
exception handling with resumption
interrupt handler
failure returning functions and expressions
exception handling by try..catch
object-defined exception handling
program control

consistency testing
dialog boxes in a user interface
error messages
error safe systems
event controlled processing
else clause
reliability of distributed systems


Exceptions are caused by one module, detected in another module, and handled in a third module. Exception handlers represent non-sequential, non-embedded, asynchronous flow of control. They can be defined by the user, defaulted by the system, or simply ignored. They should provide the cause and the location of each exception. Defining an exception handler should have minimal effect on normal behavior, while preventing the propagation of abnormal results. Execution of an exception handler should maintain the system's logical continuity. It could backtrack to a control point, re-execute the module in error, execute an alternative module, return a corrected value, or initiate an exception for a higher level handler. (cbb 5/80)
Subtopic: importance of error handling up

Quote: much of a program is for detection and handling of exceptional situations [»backRJ11_1979]
Quote: telephone control programs are more than half audit code for automatic recovery from unintended states; masks software and hardware errors [»grieD_1981]
Quote: unexpected events should be systematically handled everywhere; including commercial systems [»parnDL10_1976b]
Quote: unexpected events represent about half of the effort in writing specifications; what happens when something goes wrong? [»parnDL10_1976b]
Quote: Java uses Modula 3's exception model; it works well and must be provided; e.g., an exception caused the loss of Ariane 5 [»goslJ6_1997]
Quote: use error handling to reduce testing for rare conditions and control flow interruptions [»buhrPA9_2000]
Quote: an overall strategy is needed to use exception handlers effectively; e.g., successful fault-tolerant systems are multi-level [»stroB_1991]
QuoteRef: bateD_1976 ;;23 Hunke: "This prevents a disturbance in a system of programs from spreading
Quote: several well-structured systems in the literature without error handling [»parnDL_1977]

Subtopic: handling failure up

Quote: on failure, silently ignore the request, admit failure, resign, retry, alternative action, or appeal to a higher authority [»wirfR7_2006]
Quote: resign instead of failing fast; free up resources, clean things up, and signal definite failure; recovery isn't possible [»wirfR7_2006]

Subtopic: separate normal from worst case up

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: handle normal and worst case separately; the normal case is fast and the worst case makes progress [»lampBW10_1983]
Quote: avoid using exceptions as a control structure; keep ordinary code and error-handling code separate [»stroB_1991]
Quote: simplify error handling by keeping it separate from normal code
Quote: exceptions should be handled separately from the normal case; good use of a restricted goto [»backRJ11_1979]
Quote: separate unexpected errors and their correction from normal code [»parnDL10_1976b]
Quote: an unhandled exception raises a 'failure' exception that is either handled or generates trace-back information [»hullTE9_1988]
Quote: use one pattern for reporting errors and recovering failed processes

Subtopic: exception arguments up

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: an exception should minimize the amount of conveyed information; otherwise changes may be difficult to make [»stroB_1991]
Quote: model an exception handler as a C-- continuation; like a label with parameters; a non-local exit via 'cut to' [»ramsN6_2000]
Quote: a function failure has a result object that may include an error message

Subtopic: checked vs. unchecked exceptions up

Quote: checked expressions must be handled; suppress, bail out, propagate, base case, wrap, or translate; none are good [»goldO11_2001]
Quote: use checked exceptions when recovery is possible; use run-time exceptions for programming errors [»blocJ_2001]
Quote: checked exceptions should include methods that describe the context and cause of the error; assist with recovery [»blocJ_2001]
Quote: use checked exceptions for multiple, necessary exceptions that allow recovery [»blocJ_2001]
Quote: most handlers end up propagating type-checked expressions; worse than unchecked expressions [»goldO11_2001]
Quote: exception handling for external exceptions should be part of an interface specification [»parnDL_1977]
Quote: the exceptions signaled by a procedure are part of its abstraction
Quote: only the immediate caller should handle a procedure's exceptions; since lower-level exceptions are part of the implementation [»liskBH11_1979]
Quote: Java provides both type checked exceptions and unchecked exceptions; which is better? [»goldO11_2001]

Subtopic: restart up

Quote: software must allow restart; define a contract with descendant processes and the receipient for restart events [»shapMW12_2004]

Subtopic: trap up

Quote: use traps for unexpected events; like a hardware trap for divide by zero; separates UE code and catches UEs [»parnDL10_1976b]
Quote: the "abstract" machine detects attempts to violate its specifications; such undesired events invoke traps [»parnDL10_1976b]
Quote: gdb debugger executes one million processor cycles for each trap/resume; context switches and system calls [»bootB6_2000]

Subtopic: kinds of exception handlers up

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: error handling should be extensible for new and modified exceptions
Quote: an undesired event (UE) handler attempts recovery or adjusts its external state and reports the UE a level higher
Quote: terminate a procedure abnormally by calling an error handler; can recall it or return an appropriate result [»thimH2_1980]
Quote: error handling should be strictly hierarchical; otherwise get cycles of system dependencies if a function asks its caller for help with recovery or resource acquisition [»stroB_1991]
QuoteRef: goodJB12_1975 ;;684 on range failure: invoker terminates (partial results?) operation terminates, operation restart. clean up of partial results
QuoteRef: rossJP_1970 ;;on error condition can get info, control or suspend

Subtopic: no effect on module state up

QuoteRef: parnDL5_1972 ;;331 errors should leave module state unchanged (i.e. restartable)
QuoteRef: robiL9_1975 ;;2 exception conditions have no effect on module

Subtopic: exceptions cause type errors up

Quote: allowing exceptional instances can destroy type-safeness; e.g., using Canadian dollars instead of U.S. ones [»borgA10_1986]
Quote: exception lists are too restrictive for function signatures; interacts with type system; preclude reuse; rebranding hides low-level errors; asynchronous exceptions [»buhrPA9_2000]

Subtopic: exception translation up

Quote: exception translation -- catch low-level exceptions and throw new exceptions in terms of the high-level abstraction [»blocJ_2001]

Subtopic: exceptions difficult during initialization and finalization up

Quote: exceptions during finalization and initialization are difficult to handle properly
Quote: an object is not constructed until its constructor has completed; an exception calls a destructor only for constructed objects

Subtopic: multi-processing exceptions up

Quote: an exception in a Mach thread suspends the thread and notifies an exception handler; access thread via exception port [»tevaA11_1989]
Quote: a UNIX shell file can trap interrupts with a goto, ignore them, or use the default handler [»mashJR_1976]
Quote: V's exception server passes an exception to the registered handler for the corresponding process; otherwise invokes debugger [»cherDR4_1984]
Quote: V passes an exception hardware interrupt to the current process; it forwards the exception to an exception server; moves out of kernel [»cherDR4_1984]
Quote: need to map asynchronous events such as interrupts and exceptions to a process model as quickly as possible [»stroB_1994]
Quote: nested, asynchronous exception handling is a prescription for chaos

Subtopic: stream errors up

Quote: every I/O stream has a state associated with it; used for handling errors and non-standard conditions [»stroB_1991]
Quote: EROS truncates messages to undefined destinations; otherwise, fault handlers may lead to denial-of-service, buffering creates local state, and timeouts are not repeatable under load [»shapJS1_2002]

Subtopic: exceptions easier in batch processing up

Quote: use batch processing if possible; more efficient and simpler error recovery [»lampBW10_1983]

Subtopic: efficient exception handling up

Quote: in CLU, an exception is as efficient as a normal return; use exceptions to distinguish multiple returns [»liskB_1996]
Quote: C++ containers are exception-safe generic components; no cost for normal operation, exceptions for cost comparable to a function call [»abraD4_1998]

Subtopic: exceptions as goto's up

Quote: an exception handler may goto a nonlocal label, terminate intervening blocks, retry, or resume
Quote: Galaxy exceptions are the targets of goto's; can be assigned to variables, e.g., for jumps to outer functions [»beet5_1989]
Quote: Galaxy exceptions (targets of goto's) can be passed as arguments to functions or macros [»beet5_1989]

Group: exception handling up

Topic: backtracking (30 items)
Topic: default exception handler (3 items)
Topic: exceptions and undesired events (29 items)
Topic: exceptions from invalid input (4 items)
Topic: exception handling by recovery block or rescue clause (22 items)
Topic: exception handling by termination (16 items)
Topic: exception handling by unique value (8 items)
Topic: exception handling with resumption (31 items)
Topic: interrupt handler (20 items)
Topic: failure returning functions and expressions (24 items)
Topic: exception handling by try..catch (53 items)
Topic: object-defined exception handling
(10 items)

Related Topics up

Group: debugging   (10 topics, 333 quotes)
Group: program control   (27 topics, 547 quotes)
Group: testing   (18 topics, 557 quotes)

Topic: consistency testing (60 items)
Topic: continuation (16 items)
Topic: dialog boxes in a user interface (15 items)
Topic: error messages (37 items)
Topic: error safe systems (76 items)
Topic: event controlled processing (46 items)
Topic: else clause (11 items)
Topic: reliability of distributed systems
(35 items)

Updated barberCB 1/06
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.