[Ada Information Clearinghouse]
Ada '83 Rationale, Sec 14.1: Introduction (to Ch 14: Exception Handling)

"Rationale for the Design of the
Ada® Programming Language"

[Ada '83 Rationale, HTML Version]

Copyright ©1986 owned by the United States Government. All rights reserved.
Direct inquiries to the Ada Information Clearinghouse at adainfo@sw-eng.falls-church.va.us.

CHAPTER 14: Exception Handling

14.1 Introduction

The ability to handle error situations is essential for the reliability of real-time systems. In many cases, they must be designed as systems which should never halt. This definitely requires an ability to handle situations that, although rare, are quite likely to happen given enough time.

This subject of exception handling has received considerable attention over the years, and several formulations of exception handling features for programming languages have been proposed. For a presentation of these facilities the reader is referred to the extensive accounts given in [Go 75] and [Le 77]. The solutions proposed differ mainly in the level of generality at which they treat the concept of exception.

One family of solutions tends to consider exception handling as a normal programming technique for events that are infrequent, but are not necessarily errors. This viewpoint has been followed in [LMS 74], [Go 75], [PW 76], [Le 77] and [GS 77]. It means that when an exception occurs it is first treated by an exception handler, and then control may return to the point where the exception occurred. It also means that exception handling may be used to perform some repair actions and thereafter to continue normal execution.

A second family of proposals tends to restrict exceptions to events that can be considered (in some sense) as errors or, at least, as terminating conditions. This means that when an exception is raised in a given sequence of statements, their execution will be abandoned. Control will be passed to an exception handler but will never return to the point where the exception was raised. The handler may decide to restart the same sequence of actions under better conditions, but it will do so by a different invocation of these actions, not by a simple resumption. This second family of solutions includes recovery blocks [HLMR 74, Ra 75] and a proposal by Bron, Fokkinga, and De Haas [BFH 76].

Naturally, what is considered as an error is rather subjective, and moreover the ability of a handler to reinvoke a subprogram that raised an exception will permit the use of exception handling both for making repairs and for the treatment of rare events. The problem domains that can be addressed by the two families of solutions are hence comparable; but they require different underlying mechanisms and they lead to different programming styles.

The exception handling facility provided in Ada belongs to this second family. It provides a facility for local termination upon detection of errors. It has been inspired by the Bron proposal and has some similarities with the Bliss signal enable construct.

The discussion of exception handling starts with an overall presentation, followed by examples that illustrate the main classes of use. The interactions between exceptions and parallel processing are then presented, and we conclude with a discussion of several technical issues.

Address any questions or comments to adainfo@sw-eng.falls-church.va.us.