1------------------------------------------------------------------------------ 2-- XML/Ada - An XML suite for Ada95 -- 3-- -- 4-- Copyright (C) 2001-2018, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or modify it -- 7-- under terms of the GNU General Public License as published by the Free -- 8-- Software Foundation; either version 3, or (at your option) any later -- 9-- version. This library is distributed in the hope that it will be useful, -- 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 12-- -- 13-- As a special exception under Section 7 of GPL version 3, you are granted -- 14-- additional permissions described in the GCC Runtime Library Exception, -- 15-- version 3.1, as published by the Free Software Foundation. -- 16-- -- 17-- You should have received a copy of the GNU General Public License and -- 18-- a copy of the GCC Runtime Library Exception along with this program; -- 19-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 20-- <http://www.gnu.org/licenses/>. -- 21-- -- 22------------------------------------------------------------------------------ 23 24with Ada.Exceptions; 25with Sax.Locators; 26with Unicode.CES; 27 28package Sax.Exceptions is 29 30 ------------------- 31 -- Sax_Exception -- 32 ------------------- 33 34 type Sax_Exception (<>) is tagged private; 35 -- General type that encapsulates a general SAX error or warning. 36 -- It does not contain source location information (see Sax_Parse_Exception 37 -- instead) 38 39 function Create (Ada_Exception : Ada.Exceptions.Exception_Id) 40 return Sax_Exception'Class; 41 -- Create a new SAX exception wrapping an existing exception 42 43 function Create (Message : Unicode.CES.Byte_Sequence) 44 return Sax_Exception'Class; 45 -- Create a new SAX exception 46 47 function Create 48 (Message : Unicode.CES.Byte_Sequence; 49 Ada_Exception : Ada.Exceptions.Exception_Id) 50 return Sax_Exception'Class; 51 -- Create a new SAX exception from an existing exception 52 53 function Get_Exception (Except : Sax_Exception) 54 return Ada.Exceptions.Exception_Id; 55 -- Return the embedded exception 56 57 function Get_Message (Except : Sax_Exception) 58 return Unicode.CES.Byte_Sequence; 59 -- Return the message 60 61 ------------------------- 62 -- Sax_Parse_Exception -- 63 ------------------------- 64 65 type Sax_Parse_Exception (<>) is new Sax_Exception with private; 66 67 function Create (Message : Unicode.CES.Byte_Sequence; 68 Loc : Sax.Locators.Location) 69 return Sax_Parse_Exception'Class; 70 71 function Create 72 (Message : Unicode.CES.Byte_Sequence; 73 Ada_Exception : Ada.Exceptions.Exception_Id; 74 Loc : Sax.Locators.Location) 75 return Sax_Exception'Class; 76 -- Create a new Sax_Parse_Exception. Note: no copy of Loc is made. 77 78 function Get_Location (Except : Sax_Parse_Exception) 79 return Sax.Locators.Location; 80 -- return the location where the exception was raised. 81 82private 83 type Sax_Exception (Length : Natural) is tagged record 84 Message : Unicode.CES.Byte_Sequence (1 .. Length); 85 Except : Ada.Exceptions.Exception_Id; 86 end record; 87 pragma No_Tagged_Streams (Sax_Exception); 88 89 type Sax_Parse_Exception is new Sax_Exception with record 90 Loc : Sax.Locators.Location; 91 end record; 92end Sax.Exceptions; 93