DDC-I Logo

Sitemap  

DDC-I Ada Compiler System  
Declarative Part not Covered by Exception Handler

Product Family: Any
Target CPU: Any
Language: Ada
Host: Any

Most people (including myself) fall into this trap occasionally:

   declare
       Obj : constant := Get_Object( ... );  
                      -- Get_Object may raise exception No_Objects
   begin
       Handle( Obj );
   exception
       when No_Objects =>
          null;
   end;

Wondering why the exception in not handled? Look at (Ada95) ARM 11.2(10):
http://www.adaic.org/standards/95lrm/html/RM-11-2.html

"The execution of a handled_sequence_of_statements consists of the execution of the Sequence_of_statements. [The optional handlers are used to handle any exceptions that are propagated by the sequence_of_statements.]

Thus, exceptions propagated by the declarative_part of the block are NOT handled by the optional handlers. Instead use:

   begin
      declare
         Obj : constant := Get_Object( ... );  
                        -- may raise exception No_Objects
      begin
         Handle( Obj );
      end;
   exception
       when No_Objects =>
          null;
   end;

Contact
602-275-7172
sales@ddci.com

IDIQ Contract Vehicles:
--------------
AMCOM Express
DESP II
F2AST
R23G

Links

Support

Members Area
    -Member Login/Return
    -Login Help

Atlas Support Packages
    -Atlas Premium
    -Atlas Advantage
    -Atlas Choice

Complimentary Support

Submit a Software Trouble Report

Customer Quote:
"You have talented and dedicated people working for you. They are superlative. DRS appreciates their efforts and I personally am most grateful to be working with such an excellent group."