12. Exceptions

Exception mechanism is one of the unique features of Ada which is essential for producing reliable systems. To raise an exception is to abandon normal execution of a program and to draw attention into such situation. Such a situation has to be handled by executing some actions. For reusable components, design such a way that the reuser could handle exceptions raised, and see the following guidelines.

In Ada, exceptions are handled at the begin - end part of program units as shown below.

begin

------------ sequence of statements

exception

when Buffer_is_full => put ( " You are over writing, exception raised ");

when others => Put ( " Something else went wrong " );

end;

Guideline1 : Always define "others" as an alternative choice in exception handling construct.