1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- G N A T . E X C E P T I O N S --
11 -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
34 ------------------------------------------------------------------------------
36 -- This package provides an interface for raising predefined exceptions
37 -- with an exception message. It can be used from Pure units. This unit
38 -- is for internal use only, it is not generally available to applications.
40 package GNAT
.Exceptions
is
41 pragma Pure
(Exceptions
);
43 type Exception_Type
is limited null record;
44 -- Type used to specify which exception to raise.
46 -- Really Exception_Type is Exception_Id, but Exception_Id can't be
47 -- used directly since it is declared in the non-pure unit Ada.Exceptions,
49 -- Exception_Id is in fact simply a pointer to the type Exception_Data
50 -- declared in System.Standard_Library (which is also non-pure). So what
51 -- we do is to define it here as a by reference type (any by reference
52 -- type would do), and then Import the definitions from Standard_Library.
53 -- Since this is a by reference type, these will be passed by reference,
54 -- which has the same effect as passing a pointer.
56 -- This type is not private because keeping it by reference would require
57 -- defining it in a way (e.g a tagged type) that would drag other run time
58 -- files, which is unwanted in the case of e.g ravenscar where we want to
59 -- minimize the number of run time files needed by default.
61 CE
: constant Exception_Type
; -- Constraint_Error
62 PE
: constant Exception_Type
; -- Program_Error
63 SE
: constant Exception_Type
; -- Storage_Error
64 TE
: constant Exception_Type
; -- Tasking_Error
65 -- One of these constants is used in the call to specify the exception
67 procedure Raise_Exception
(E
: Exception_Type
; Message
: String);
68 pragma Import
(Ada
, Raise_Exception
, "__gnat_raise_exception");
69 pragma No_Return
(Raise_Exception
);
70 -- Raise specified exception with specified message
73 pragma Import
(C
, CE
, "constraint_error");
74 pragma Import
(C
, PE
, "program_error");
75 pragma Import
(C
, SE
, "storage_error");
76 pragma Import
(C
, TE
, "tasking_error");
77 -- References to the exception structures in the standard library