Content deleted Content added
No edit summary |
Phil Boswell (talk | contribs) →[[Ada (programming language)|Ada]]: <source> |
||
Line 8:
==== Exception declarations ====
<source lang=ada>
</source>
==== Raising exceptions ====
<source lang=ada>
raise Some_Error;
</source>
'''raise''' Some_Error '''with''' "Out of memory"; -- specific diagnostic message▼
==== Exception handling and propagation ====
<source lang=ada>
▲ '''with''' Ada.Exceptions, Ada.Text_IO;
▲ '''procedure''' Foo '''is'''
▲ Some_Error : '''exception''';
▲ '''begin'''
when Constraint_Error =>
▲ Do_Something_Interesting;
▲ '''exception''' ''-- Start of exception handlers''
▲ ''... -- Handle constraint error''
▲ ''-- Propagate Storage_Error as a different exception with a useful message''
Ada.Text_IO.Put("Exception: ");
▲ '''when''' Error : '''others''' =>
▲ ''-- Handle all others''
▲ Ada.Text_IO.Put_Line(Ada.Exceptions.Exception_Name(Error));
</source>
▲ '''end''' Foo;
=== [[BASIC]] ===
|