gm2-libs-iso/EXCEPTIONS (The GNU Modula-2 Compiler)

#### 4.4.10 gm2-libs-iso/EXCEPTIONS ¶

    DEFINITION MODULE EXCEPTIONS;

    (* Provides facilities for raising user exceptions
       and for making enquiries concerning the current execution state.
    *)

    TYPE
      ExceptionSource;   (* values of this type are used within library
                            modules to identify the source of raised
                            exceptions *)
      ExceptionNumber = CARDINAL;

    PROCEDURE AllocateSource(VAR newSource: ExceptionSource);
      (* Allocates a unique value of type ExceptionSource *)

    PROCEDURE RAISE (source: ExceptionSource;
                     number: ExceptionNumber; message: ARRAY OF CHAR)
                     <* noreturn *> ;
      (* Associates the given values of source, number and message with
         the current context and raises an exception.
      *)

    PROCEDURE CurrentNumber (source: ExceptionSource): ExceptionNumber;
      (* If the current coroutine is in the exceptional execution state
         because of the raising of an exception from source, returns
         the corresponding number, and otherwise raises an exception.
      *)

    PROCEDURE GetMessage (VAR text: ARRAY OF CHAR);
      (* If the current coroutine is in the exceptional execution state,
         returns the possibly truncated string associated with the
         current context.  Otherwise, in normal execution state,
         returns the empty string.
      *)

    PROCEDURE IsCurrentSource (source: ExceptionSource): BOOLEAN;
      (* If the current coroutine is in the exceptional execution state
         because of the raising of an exception from source, returns
         TRUE, and otherwise returns FALSE.
      *)

    PROCEDURE IsExceptionalExecution (): BOOLEAN;
      (* If the current coroutine is in the exceptional execution state
         because of the raising of an exception, returns TRUE, and
         otherwise returns FALSE.
      *)

    END EXCEPTIONS.