home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / Z1 < prev    next >
Encoding:
Text File  |  1992-06-07  |  3.1 KB  |  110 lines

  1. #ifndef __RWERR_H__
  2. #define __RWERR_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * Error definitions
  7.  *
  8.  * $Header:   E:/vcs/rw/rwerr.h_v   1.5   18 Feb 1992 09:54:38   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * This error facility has been designed to work in a generic environment, hence it
  23.  * can't take advantage of all those wonderful Tools.h++ classes to make
  24.  * life simpler.
  25.  *
  26.  * $Log:   E:/vcs/rw/rwerr.h_v  $
  27.  * 
  28.  *    Rev 1.5   18 Feb 1992 09:54:38   KEFFER
  29.  * 
  30.  *    Rev 1.4   12 Nov 1991 13:15:30   keffer
  31.  * Now guaranteed that a package will be inserted into the error handler
  32.  * before an error of that type can occur.
  33.  * 
  34.  *    Rev 1.3   17 Oct 1991 09:13:02   keffer
  35.  * Changed include path to <rw/xxx.h>
  36.  * 
  37.  *    Rev 1.1   24 Jul 1991 13:06:48   keffer
  38.  * Added pvcs keywords
  39.  *
  40.  */
  41.  
  42. #include "rw/defs.h"
  43. #include <stdarg.h>
  44.  
  45. /*
  46.  * This struct contains all the information about an error.
  47.  * Currently, it consists of a default disposition, and a message.
  48.  */
  49. struct RWErrType {
  50.   RWSeverity    defaultDispose;    // Default error disposition
  51.   const char*    errmsg;        // The associated error message.
  52. };
  53.  
  54. /*
  55.  * All of the error messages associated with a package are managed by an
  56.  * instance of RWPackage.
  57.  */
  58. struct RWPackage {
  59.   int            packNo;    // Package number
  60.   const RWErrType*    errs;    // The vector of errors for this package
  61.   unsigned        nerrs;    // Number of errors
  62.   RWPackage*        next;    // Points to next package
  63. public:
  64.   const RWErrType*    getError(RWErrNo) const;
  65.   int            packageID() const {return packNo;}
  66. };
  67.  
  68. /*
  69.  * The error manager manages all packages.  It maintains a linked
  70.  * list of RWPackage instances.  Note that everything is declared static:
  71.  * there is only one global error manager.
  72.  */
  73. class RWExport RWErrManager {
  74.   static RWPackage*    packageList; // Head of the list
  75. public:
  76.   // Add a new package:
  77.   static void            insert(RWPackage*);
  78.   static RWPackage*        remove(int packageNumber);
  79.   // Get a error struct for a given error number:
  80.   static const RWErrType*    getErr(RWErrNo);
  81. };
  82.  
  83. /*
  84.  * An instance of class RWErrObject is used to raise an error/exception.
  85.  */
  86. class RWExport RWErrObject {
  87. public:
  88.   RWErrObject(RWErrNo n, RWSeverity sever = RWDEFAULT, ClassID cl = __GLOBAL);
  89.   RWErrNo        number() const   {return errorNumber;}
  90.   RWSeverity        severity() const {return sev;}
  91.   ClassID        classID() const  {return theClass;}
  92. private:
  93.   RWErrNo        errorNumber;
  94.   RWSeverity        sev;
  95.   ClassID        theClass;
  96. };
  97.  
  98. /*
  99.  * typedef for an error handler:
  100.  */
  101. typedef void (far *RWErrHandler)(RWErrObject, va_list);
  102.  
  103. /*
  104.  * Set a new error handler.
  105.  */
  106. RWErrHandler rwexport setRWErrHandler(RWErrHandler routine);
  107.  
  108. pragma pop_align_members();
  109. #endif /* __RWERR_H__ */
  110.