home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnth0109.zip / Timur / errors.h < prev    next >
Text File  |  1993-06-07  |  3KB  |  98 lines

  1. /* ERRORS.H
  2.  
  3. Copyright (c) 1992-1993 Timur Tabi
  4. Copyright (c) 1992-1993 Fasa Corporation
  5.  
  6. The following trademarks are the property of Fasa Corporation:
  7. BattleTech, CityTech, AeroTech, MechWarrior, BattleMech, and 'Mech.
  8. The use of these trademarks should not be construed as a challenge to these marks.
  9.  
  10. The error codes are decimal numbers that are unique to:
  11.  
  12. 1. Module
  13. 2. Function in the module
  14. 3. Error condition in the function
  15.  
  16. So each error code should, theoretically, tell you exactly where
  17. the error code occurred.  It does not, however, tell you how it
  18. got there.  If anyone knows how to do this without much hassle,
  19. please let me know.
  20.  
  21. The error codes usually apply to OS/2 functions that have failed.
  22. The functions that have nothing to do with OS/2 API's
  23. usually don't need such a sophisticated error scheme.
  24.  
  25. If function x calls function y, and function y returns an error
  26. code, then function x will return the same error code (after
  27. cleaning up any allocated resources that no longer apply), but
  28. only if function x calls function y IN ONE PLACE.  That is,
  29. if there are two calls to function y, then function x cannot simply
  30. pass the error code back.  In fact, it's a bad idea if function
  31. x calls function y in more than one place anyway.  The sequence
  32. of function which caused the error becomes difficult to determine.
  33.  
  34. The values are constructed as follows.  The 32-bit unsigned value
  35. is divided into 8 hexadecimal digits.
  36.  
  37. __000000 Indicates the module.  This allows room for 256 modules
  38. 00__0000 Indicates the function within that module.  This allows 256 functions per module
  39. 0000__00 Indicates the location or API call within the function.  Allows 256 per function
  40. 000000__ is extra information available
  41. */
  42.  
  43. typedef unsigned ERROR;           // 32-bit error code
  44.  
  45. /*
  46. If function x calls function y, and function y returns a non-zero error code, then this
  47. define will cause function x to exit immediately while returning the same error code.
  48. It uses the global variable gec (Global Error Code), which acts more like temporary
  49. storage than a global variable.
  50. */
  51. #define RETURN(e) if ((gec=(e)) != 0) return gec
  52.  
  53. #ifdef ERRORS_C
  54. #define EXTERN
  55. #else
  56. #define EXTERN extern
  57. #endif
  58.  
  59. EXTERN ERROR gec;
  60.  
  61. #undef EXTERN
  62.  
  63.  
  64. #define ERR_NOERROR  0
  65.  
  66. // bitmap.c
  67. #define ERR_BITMAP 0x01000000
  68. #define ERR_BITMAP_SHUT (ERR_BITMAP + 0x010000)
  69. #define ERR_BITMAP_SHUT_PS            (ERR_BITMAP_SHUT + 0x0100)   // Could not destroy PS
  70. #define ERR_BITMAP_SHUT_DC            (ERR_BITMAP_SHUT + 0x0200)   // Could not close DC
  71.  
  72. #define ERR_BITMAP_LOAD (ERR_BITMAP + 0x020000)
  73. #define ERR_BITMAP_LOAD_DC            (ERR_BITMAP_LOAD + 0x0100)   // Could not open DC
  74. #define ERR_BITMAP_LOAD_PS            (ERR_BITMAP_LOAD + 0x0200)   // Could not create PS
  75. #define ERR_BITMAP_LOAD_HBM           (ERR_BITMAP_LOAD + 0x0300)   // Could not load bitmap
  76.  
  77. // mech.c
  78. #define ERR_MECH 0x03000000
  79.  
  80. // menu.c
  81. #define ERR_MENU 0x04000000
  82.  
  83. // target.c
  84. #define ERR_TARGET 0x05000000
  85.  
  86. // files.c
  87. #define ERR_FILES 0x06000000
  88. #define ERR_FILES_CANCEL              (ERR_FILES + 0x000100)       // User cancelled a load/save
  89. #define ERR_FILES_DLG                 (ERR_FILES + 0x000200)       // WinFileDlg() failed somehow
  90.  
  91. // terrain.c
  92. #define ERR_TERR 0x07000000
  93. #define ERR_TERR_INIT (ERR_TERR + 0x010000)
  94.  
  95. ERROR ErrorBox(ERROR);
  96. APIRET ErrorDosError(APIRET);
  97. void ErrorWinError(void);
  98.