home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / MyErrors.p < prev    next >
Encoding:
Text File  |  1996-12-25  |  1.1 KB  |  54 lines  |  [TEXT/CWIE]

  1. unit MyErrors;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types;
  7.  
  8.     const
  9.         error_id = 925; { STR#, ERRS, ALRT, DITL.  override ERRS with ERRS=128 }
  10.  
  11.     procedure DisplayError (msg: integer; err: OSErr);
  12.     procedure DisplayErrorString ( const msg: Str255; err: OSErr); { ^1 -> err }
  13.     function GetErrorStr( err: OSErr ): Str255;
  14.  
  15. implementation
  16.  
  17.     uses
  18.         Errors, TextUtils, 
  19.         MyErrorStrings, MyCleverAlerts, MyStrings;
  20.  
  21.     procedure DisplayError (msg: integer; err: OSErr);
  22.         var
  23.             s: Str255;
  24.     begin
  25.         GetIndString( s, error_id, msg );
  26.         DisplayErrorString( s, err );
  27.     end;
  28.     
  29.     function GetErrorStr( err: OSErr ): Str255;
  30.         var
  31.             e: Str255;
  32.     begin
  33.         if not ErrorString(128, err, e) then begin
  34.             e := ErrorStr(error_id, err);
  35.         end;
  36.         GetErrorStr := e;
  37.     end;
  38.  
  39.     procedure DisplayErrorString ( const msg: Str255; err: OSErr);
  40.         var
  41.             s, e: Str255;
  42.     begin
  43.         if (err <> noErr) & (err <> userCanceledErr) then begin
  44.             if not ErrorString(128, err, e) then begin
  45.                 e := ErrorStr(error_id, err);
  46.             end;
  47.             s := msg;
  48.             SPrintS3(s, s, e, '', '');
  49.             CleverParamText('', s, '', '');
  50.             CleverNotifyAlert(error_id);
  51.         end;
  52.     end;
  53.  
  54. end.