Interrupts are triggered asynchronously by an I/O device, and allow the program to be restarted with no loss of continuity. Using x86 terminology, there are four types of events: interrupts, faults, traps, and aborts. From the implementation point of view, all of these are handled identically: the processor halts execution of the current program, looks up the interrupt handler in the interrupt vector table for that exception or interrupt condition, saves state, and switches control. For example, ARM considers interrupts to be a type of hardware exception, while x86 does not. There is no clear consensus as to the exact meaning of terms like exceptions, faults, aborts, traps, and interrupts with respect to hardware. Depending on context, this "key absent" exception may occur much more often than a successful lookup. For example, suppose a lookup function in an associative array throws an exception if the key has no value associated.
Even the term "exception" may be misleading because its typical connotation of "outlier" indicates that something infrequent or unusual has occurred, when in fact the exception may be a normal and usual situation in the program. The term "exception" is preferred to "error" because it does not imply that anything is wrong - a condition viewed as an error by one procedure or programmer may not be viewed that way by another.
For example the return code and errno pattern found in C may be considered to be a form of exception handling. Taking a broad view, errors can be considered to be a proper subset of exceptions. the programmer may deem division by zero to be undefined, hence an exception, or devise some behavior such as returning zero or a special "ZERO DIVIDE" value (circumventing the need for exceptions). The set of "normal" circumstances is defined entirely by the programmer, e.g.
The precondition, and the definition of exception, is subjective. The exception handling mechanism then handles the exception. An exception handling mechanism allows the procedure to raise an exception if this precondition is violated, for example if the procedure has been called on an abnormal set of arguments. The definition of an exception is based on the observation that each procedure has a precondition, a set of circumstances for which it will terminate "normally". 4.12.2 Restarts separate mechanism from policy.4.7 Exception handling based on design by contract.4.5 Exception handling in UI hierarchies.4.4 Exception support in programming languages.4.2 Termination and resumption semantics.