1 ------------------------------------------------------------------------------
3 -- GNAT LIBRARY COMPONENTS --
5 -- G N A T . C U R R E N T _ E X C E P T I O N --
9 -- Copyright (C) 1996-2000 Ada Core Technologies, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package provides routines for obtaining the current exception
35 -- information in Ada 83 style. In Ada 83, there was no official method
36 -- for obtaining exception information, but a number of vendors supplied
37 -- routines for this purpose, and this package closely approximates the
38 -- interfaces supplied by DEC Ada 83 and VADS Ada.
40 -- The routines in this package are associated with a particular exception
41 -- handler, and can only be called from within an exception handler. See
42 -- also the package GNAT.Most_Recent_Exception, which provides access to
43 -- the most recently raised exception, and is not limited to static calls
44 -- from an exception handler.
46 package GNAT.Current_Exception is
47 pragma Pure (Current_Exception);
53 function Exception_Information return String;
54 -- Returns the result of calling Ada.Exceptions.Exception_Information
55 -- with an argument that is the Exception_Occurrence corresponding to
56 -- the current exception. Returns the null string if called from outside
57 -- an exception handler.
59 function Exception_Message return String;
60 -- Returns the result of calling Ada.Exceptions.Exception_Message with
61 -- an argument that is the Exception_Occurrence corresponding to the
62 -- current exception. Returns the null string if called from outside an
65 function Exception_Name return String;
66 -- Returns the result of calling Ada.Exceptions.Exception_Name with
67 -- an argument that is the Exception_Occurrence corresponding to the
68 -- current exception. Returns the null string if called from outside
69 -- an exception handler.
71 -- Note: all these functions return useful information only if
72 -- called statically from within an exception handler, and they
73 -- return information about the exception corresponding to the
74 -- handler in which they appear. This is NOT the same as the most
75 -- recently raised exception. Consider the example:
78 -- when Constraint_Error =>
82 -- when Tasking_Error => ...
85 -- -- Exception_xxx at this point returns the information about
86 -- -- the constraint error, not about any exception raised within
87 -- -- the nested block since it is the static nesting that counts.
89 -----------------------------------
90 -- Use of Library Level Renaming --
91 -----------------------------------
93 -- For greater compatibility with existing legacy software, library
94 -- level renaming may be used to create a function with a name matching
95 -- one that is in use. For example, some versions of VADS Ada provided
96 -- a functin called Current_Exception whose semantics was identical to
97 -- that of GNAT. The following library level renaming declaration:
99 -- with GNAT.Current_Exception;
100 -- function Current_Exception
101 -- renames GNAT.Current_Exception.Exception_Name;
103 -- placed in a file called current_exception.ads and compiled into the
104 -- application compilation environment, will make the function available
105 -- in a manner exactly compatible with that in VADS Ada 83.
108 pragma Import (Intrinsic, Exception_Information);
109 pragma Import (intrinsic, Exception_Message);
110 pragma Import (Intrinsic, Exception_Name);
112 end GNAT.Current_Exception;