How to resolve the algorithm Exceptions step by step in the Ada programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Exceptions step by step in the Ada programming language
Table of Contents
Problem Statement
This task is to give an example of an exception handling routine and to "throw" a new exception.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Exceptions step by step in the Ada programming language
Source code in the ada programming language
Foo_Error : exception;
procedure Foo is
begin
raise Foo_Error;
end Foo;
...
exception
when Foo_Error =>
if ... then -- Alas, cannot handle it here,
raise; -- continue propagation of
end if;
procedure Call_Foo is
begin
Foo;
exception
when Foo_Error =>
... -- do something
when others =>
... -- this catches all other exceptions
end Call_Foo;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
begin
...
Raise_Exception (Foo_Error'Identity, "This is the exception message");
..
exception
when Error : others =>
Put_Line ("Something is wrong here" & Exception_Information (Error));
end Main;
You may also check:How to resolve the algorithm Combinations step by step in the E programming language
You may also check:How to resolve the algorithm Empty program step by step in the ML/I programming language
You may also check:How to resolve the algorithm Repeat a string step by step in the Visual Basic programming language
You may also check:How to resolve the algorithm Collections step by step in the Lua programming language
You may also check:How to resolve the algorithm Draw a sphere step by step in the ERRE programming language