DEFINITION MODULE errors;

 (* 
       By: Greg Mumm
     
      "FatalError" will close all files, cleanup memory and HALT the program.

      WARNING: Memory allocations are freed with a call to "freeheap". Make
               sure any memory allocations are set up with this in mind!
 *)

FROM FileSystem IMPORT File;

FROM Scan       IMPORT NameString, STRING;

TYPE 

     ErrorType =
               ( none,
                 FileError,
                 FileNotOpened,
                 Scan_DataPastEndOfLine,
                 OutOfMemory,
                 FileClose,
                 MultipleModule,
                 UserHalt,
                 CliHelp,              (* Prints simple help information  *)
                 WorkBench,
                 NoProgramName,
                 NoSupportDEFINITION,
                 NoSupportIMPLEMENTATION,
                 NoSupportFiles,
                 NoSupportGeneric,
                 WriteStatement,
                 UndeterminedProcedure
 
               );


 (* Fatal error--clean up memory and close all files 
 *)

PROCEDURE FatalError   ( message   : ErrorType ); 


  (* Non fatal error-just print the error 
  *)
PROCEDURE ErrorMessage ( message   : ErrorType ); 



   (* Error concerning a file. The fact that we know it has something to
      do with a file allows us to to print line numbers etc..     
   *)
PROCEDURE ErrorFileMessage ( message    : ErrorType ;
                             name       : NameString    ;
                             LineNumber : CARDINAL );


   (* Internal error in a module somewhere. This type error should not
      happen on a properly running program. All memory is de-allocated,
      Everything including files are cleaned up and closed
   *)

PROCEDURE internal ( AlertString : STRING );


   (* Clean Up memory, close all files 
    *)
PROCEDURE CleanUp ();

END errors.
