IMPLEMENTATION MODULE EXCEPTIONS; (* ISO EXCEPTIONS implemented over the V3 runtime binding. The opaque ExceptionSource is an identity token; it is never dereferenced. *) FROM SYSTEM IMPORT ADDRESS; IMPORT SysExceptions; IMPORT M2EXCEPTION; TYPE ExceptionSource = ADDRESS; PROCEDURE AllocateSource (VAR newSource : ExceptionSource); BEGIN newSource := SysExceptions.NewSource() END AllocateSource; PROCEDURE RAISE (source : ExceptionSource; number : ExceptionNumber; message : ARRAY OF CHAR); BEGIN SysExceptions.RaiseUser(source, number, message) END RAISE; PROCEDURE CurrentNumber (source : ExceptionSource) : ExceptionNumber; BEGIN IF SysExceptions.IsSource(source) THEN RETURN SysExceptions.Number() ELSE SysExceptions.RaiseLang(ORD(M2EXCEPTION.exException)); RETURN 0 END END CurrentNumber; PROCEDURE GetMessage (VAR text : ARRAY OF CHAR); BEGIN SysExceptions.CopyMessage(text) END GetMessage; PROCEDURE IsCurrentSource (source : ExceptionSource) : BOOLEAN; BEGIN RETURN SysExceptions.IsSource(source) END IsCurrentSource; PROCEDURE IsExceptionalExecution () : BOOLEAN; BEGIN RETURN SysExceptions.Active() END IsExceptionalExecution; END EXCEPTIONS.