home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / errors.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-06  |  10KB  |  295 lines

  1. {*      ERRORS.PAS
  2.  *
  3.  * MIDAS Sound System error codes and error message strings
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. *}
  13.  
  14.  
  15. unit Errors;
  16.  
  17.  
  18. interface
  19.  
  20.  
  21. const
  22.     MAXERRORS = 256;                    { maximum number of errors to store }
  23.  
  24.  
  25.  
  26. {****************************************************************************\
  27. *       enum ErrorCodes
  28. *       ---------------
  29. * Description:  MIDAS Sound System error codes
  30. \****************************************************************************}
  31.  
  32. const
  33.     OK = 0;                             { no error }
  34.     errUndefined = 01;                  { undefined error }
  35.     errOutOfMemory = 02;                { out of (conventional) memory }
  36.     errHeapCorrupted = 03;              { (conventional memory) heap
  37.                                            corrupted }
  38.     errInvalidBlock = 04;               { invalid memory block }
  39.     errOutOfEMS = 05;                   { out of EMS memory }
  40.     errEMSHeapCorrupted = 06;           { EMS heap corrupted }
  41.     errInvalidEMSBlock = 07;            { invalid EMS memory block }
  42.     errEMMFailure = 08;                 { Expanded Memory Manager failure }
  43.     errOutOfCardMemory = 09;            { out of soundcard memory }
  44.     errCardHeapCorrupted = 10;          { soundcard heap corrupted }
  45.     errInvalidCardBlock = 11;           { invalid soundcard memory block }
  46.     errNoInstHandles = 12;              { out of instrument handles }
  47.     errFileOpen = 13;                   { unable to open file }
  48.     errFileRead = 14;                   { unable to read file }
  49.     errInvalidModule = 15;              { invalid module file }
  50.     errInvalidInst = 16;                { invalid instrument in module }
  51.     errInvalidPatt = 17;                { invalid pattern data in module }
  52.     errInvalidChanNumber = 18;          { invalid channel number }
  53.     errInvalidInstHandle = 19;          { invalid instrument handle }
  54.     errNoChannels = 20;                 { Sound Device channels not open }
  55.     errSDFailure = 21;                  { Sound Device hardware failure }
  56.     errInvalidArguments = 22;           { invalid function arguments }
  57.     errFileNotFound = 23;               { file not found }
  58.     errInvalidFileHandle = 24;          { invalid file handle }
  59.     errAccessDenied = 25;               { access denied }
  60.     errFileExists = 26;                 { file exists }
  61.     errTooManyFiles = 27;               { too many open files }
  62.     errDiskFull = 28;                   { disk full }
  63.     errEndOfFile = 29;                  { unexpected end of file }
  64.     errInvalidPath = 30;                { invalid path }
  65.     errFileWrite = 31;                  { unable to write file }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. {****************************************************************************\
  72. *       enum FunctionIDs
  73. *       ----------------
  74. * Description:  ID numbers for first functions in all modules
  75. \****************************************************************************}
  76.  
  77.     ID_error = 0;                       { error handling }
  78.     ID_dma = 100;                       { DMA handling routines }
  79.     ID_dsm = 200;                       { Digital Sound Mixer }
  80.     ID_ems = 300;                       { EMS heap manager }
  81.     ID_mem = 400;                       { Conventional memory management }
  82.     ID_mod = 500;                       { Protracker Module Player }
  83.     ID_s3m = 600;                       { Scream Tracker 3 Module Player }
  84.     ID_tmr = 700;                       { TempoTimer }
  85.     ID_vu = 800;                        { Real VU meters }
  86.     ID_rf = 900;                        { Raw file I/O }
  87.     ID_file = 1000;                     { High-level file I/O }
  88.     ID_gus = 2000;                      { GUS Sound Device }
  89.     ID_pas = 2100;                      { PAS Sound Device }
  90.     ID_wss = 2200;                      { WSS Sound Device }
  91.     ID_sb = 2300;                       { SB Sound Device }
  92.     ID_nsnd = 2900;                     { No Sound Sound Device }
  93.  
  94.  
  95.  
  96. {****************************************************************************\
  97. *       Error message strings:
  98. \****************************************************************************}
  99.  
  100. const
  101.     errorMsg : array[0..31] of string = (
  102.         'OK',
  103.         'Undefined error',
  104.         'Out of conventional memory',
  105.         'Conventional memory heap corrupted',
  106.         'Invalid conventional memory block',
  107.         'Out of EMS memory',
  108.         'EMS memory heap corrupted',
  109.         'Invalid EMS memory block',
  110.         'Expanded Memory Manager failure',
  111.         'Out of soundcard memory',
  112.         'Soundcard memory heap corrupted',
  113.         'Invalid soundcard memory block',
  114.         'Out of instrument handles',
  115.         'Unable to open file',
  116.         'Unable to read file',
  117.         'Invalid module file',
  118.         'Invalid instrument in module',
  119.         'Invalid pattern data in module',
  120.         'Invalid channel number',
  121.         'Invalid instrument handle',
  122.         'Sound Device channels not open',
  123.         'Sound Device hardware failure',
  124.         'Invalid function arguments',
  125.         'File does not exist',
  126.         'Invalid file handle',
  127.         'Access denied',
  128.         'File exists',
  129.         'Too many open files',
  130.         'Disk full',
  131.         'Unexpected end of file',
  132.         'Invalid path',
  133.         'Unable to write file' );
  134.  
  135.  
  136.  
  137. {$IFDEF DEBUG}
  138.  
  139. {****************************************************************************\
  140. *       struct errRecord
  141. *       ----------------
  142. * Description:  Error record for error list
  143. \****************************************************************************}
  144.  
  145. type
  146.     errRecord = Record
  147.         errorCode : integer;            { error code number }
  148.         functID : word;                 { ID for function that caused the
  149.                                           error }
  150.     end;
  151.  
  152.  
  153.  
  154. {****************************************************************************\
  155. *
  156. * Function:     errAdd(errorCode : integer; functID : word);
  157. *
  158. * Description:  Add an error to error list
  159. *
  160. * Input:        errorCode : integer     error code
  161. *               functID : word          ID for function that caused the error
  162. *
  163. \****************************************************************************}
  164.  
  165. procedure errAdd(errorCode : integer; functID : word);
  166.  
  167.  
  168.  
  169. {****************************************************************************\
  170. *
  171. * Function:     errPrintList;
  172. *
  173. * Description:  Prints the error list to stderr
  174. *
  175. \****************************************************************************}
  176.  
  177. procedure errPrintList;
  178.  
  179.  
  180. {$ENDIF}
  181.  
  182.  
  183.  
  184. {****************************************************************************\
  185. *
  186. * Function:     mError(errCode : integer; functID : word);
  187. *
  188. * Description:  Adds an error to the MIDAS error list if DEBUG is defined.
  189. *               Does nothing otherwise
  190. *
  191. * Input:        errCode : integer       error code
  192. *               functID : word          ID for function that caused the error
  193. *
  194. \****************************************************************************}
  195.  
  196. procedure mError(errCode : integer; functID : word);
  197.  
  198.  
  199.  
  200.  
  201. implementation
  202.  
  203.  
  204.  
  205. {$IFDEF DEBUG}
  206.  
  207. var
  208.     errorList : array[0..MAXERRORS-1] of errRecord;     { error list }
  209.     numErrors : word;                   { number of errors in list }
  210.  
  211.  
  212. {****************************************************************************\
  213. *
  214. * Function:     errAdd(errorCode : integer; functID : word);
  215. *
  216. * Description:  Add an error to error list
  217. *
  218. * Input:        errorCode : integer     error code
  219. *               functID : word          ID for function that caused the error
  220. *
  221. \****************************************************************************}
  222.  
  223. procedure errAdd(errorCode : integer; functID : word);
  224. begin
  225.     { make sure that error list does not overflow }
  226.     if numErrors <= MAXERRORS then
  227.     begin
  228.         { store error information to list: }
  229.         errorList[numErrors].errorCode := errorCode;
  230.         errorList[numErrors].functID := functID;
  231.         numErrors := numErrors + 1;
  232.     end;
  233. end;
  234.  
  235.  
  236.  
  237. {****************************************************************************\
  238. *
  239. * Function:     errPrintList;
  240. *
  241. * Description:  Prints the error list to stderr
  242. *
  243. \****************************************************************************}
  244.  
  245. procedure errPrintList;
  246. var
  247.     i : word;
  248. begin
  249.     WriteLn('MIDAS error list:');
  250.  
  251.     if numErrors > 0 then
  252.     begin
  253.         for i := 0 to (numErrors-1) do
  254.         begin
  255.             WriteLn(i, ': <',errorList[i].errorCode, ', ', errorList[i].functID,
  256.                 '> - ', errorMsg[errorList[i].errorCode], ' at ',
  257.                 errorList[i].functID);
  258.         end;
  259.     end;
  260. end;
  261.  
  262.  
  263. {$ENDIF}
  264.  
  265.  
  266.  
  267. {****************************************************************************\
  268. *
  269. * Function:     mError(errCode : integer; functID : word);
  270. *
  271. * Description:  Adds an error to the MIDAS error list if DEBUG is defined.
  272. *               Does nothing otherwise
  273. *
  274. * Input:        errCode : integer       error code
  275. *               functID : word          ID for function that caused the error
  276. *
  277. \****************************************************************************}
  278.  
  279. procedure mError(errCode : integer; functID : word);
  280. begin
  281. {$IFDEF DEBUG}
  282.     errAdd(errCode, functID);
  283. {$ENDIF}
  284. end;
  285.  
  286.  
  287.  
  288.  
  289.  
  290. BEGIN
  291. {$IFDEF DEBUG}
  292.     numErrors := 0;
  293. {$ENDIF}
  294. END.
  295.