1 (* GeneralUserExceptions.mod implement the ISO GeneralUserExceptions.
3 Copyright (C) 2002-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 IMPLEMENTATION MODULE GeneralUserExceptions
;
29 FROM EXCEPTIONS
IMPORT ExceptionSource
, RAISE
, AllocateSource
, CurrentNumber
,
30 IsCurrentSource
, IsExceptionalExecution
;
32 FROM M2RTS
IMPORT NoException
;
33 FROM SYSTEM
IMPORT ADR
;
37 general
: ExceptionSource
;
41 RaiseGeneralException - raises exception using text as the associated
45 PROCEDURE RaiseGeneralException (exception
: GeneralExceptions
; text
: ARRAY OF CHAR) ;
47 RAISE (general
, ORD (exception
), text
)
48 END RaiseGeneralException
;
52 IsGeneralException - returns TRUE if the current coroutine is in the
53 exceptional execution state because of the raising
54 of an exception from GeneralExceptions; otherwise
58 PROCEDURE IsGeneralException () : BOOLEAN ;
60 RETURN IsExceptionalExecution () AND IsCurrentSource (general
)
61 END IsGeneralException
;
65 GeneralException - if the current coroutine is in the exceptional
66 execution state because of the raising of an
67 exception from GeneralExceptions, returns the
68 corresponding enumeration value, and otherwise
72 PROCEDURE GeneralException () : GeneralExceptions
;
74 IF IsGeneralException ()
76 RETURN VAL (GeneralExceptions
, CurrentNumber (general
))
78 NoException (ADR (__FILE__
), __LINE__
,
79 __COLUMN__
, ADR (__FUNCTION__
),
80 ADR ("not in the exceptional execution state"))
82 END GeneralException
;
86 AllocateSource (general
)
87 END GeneralUserExceptions.