| 1 |
(* Library module defined by the International Standard |
| 2 |
Information technology - programming languages |
| 3 |
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language. |
| 4 |
|
| 5 |
Copyright ISO/IEC (International Organization for Standardization |
| 6 |
and International Electrotechnical Commission) 1996-2021. |
| 7 |
|
| 8 |
It may be freely copied for the purpose of implementation (see page |
| 9 |
707 of the Information technology - Programming languages Part 1: |
| 10 |
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *) |
| 11 |
|
| 12 |
DEFINITION MODULE EXCEPTIONS; |
| 13 |
|
| 14 |
(* Provides facilities for raising user exceptions |
| 15 |
and for making enquiries concerning the current execution state. |
| 16 |
*) |
| 17 |
|
| 18 |
TYPE |
| 19 |
ExceptionSource; (* values of this type are used within library |
| 20 |
modules to identify the source of raised |
| 21 |
exceptions *) |
| 22 |
ExceptionNumber = CARDINAL; |
| 23 |
|
| 24 |
PROCEDURE AllocateSource(VAR newSource: ExceptionSource); |
| 25 |
(* Allocates a unique value of type ExceptionSource *) |
| 26 |
|
| 27 |
PROCEDURE RAISE (source: ExceptionSource; |
| 28 |
number: ExceptionNumber; message: ARRAY OF CHAR) |
| 29 |
<* noreturn *> ; |
| 30 |
(* Associates the given values of source, number and message with |
| 31 |
the current context and raises an exception. |
| 32 |
*) |
| 33 |
|
| 34 |
PROCEDURE CurrentNumber (source: ExceptionSource): ExceptionNumber; |
| 35 |
(* If the current coroutine is in the exceptional execution state |
| 36 |
because of the raising of an exception from source, returns |
| 37 |
the corresponding number, and otherwise raises an exception. |
| 38 |
*) |
| 39 |
|
| 40 |
PROCEDURE GetMessage (VAR text: ARRAY OF CHAR); |
| 41 |
(* If the current coroutine is in the exceptional execution state, |
| 42 |
returns the possibly truncated string associated with the |
| 43 |
current context. Otherwise, in normal execution state, |
| 44 |
returns the empty string. |
| 45 |
*) |
| 46 |
|
| 47 |
PROCEDURE IsCurrentSource (source: ExceptionSource): BOOLEAN; |
| 48 |
(* If the current coroutine is in the exceptional execution state |
| 49 |
because of the raising of an exception from source, returns |
| 50 |
TRUE, and otherwise returns FALSE. |
| 51 |
*) |
| 52 |
|
| 53 |
PROCEDURE IsExceptionalExecution (): BOOLEAN; |
| 54 |
(* If the current coroutine is in the exceptional execution state |
| 55 |
because of the raising of an exception, returns TRUE, and |
| 56 |
otherwise returns FALSE. |
| 57 |
*) |
| 58 |
|
| 59 |
END EXCEPTIONS. |