home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / iexcept.hp_ / IEXCEPT.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  7.6 KB  |  167 lines

  1. #if !defined( _IEXCEPT_ )
  2.   #define _IEXCEPT_
  3. /****************************************************************/
  4. /* CLASS NAMES: IExceptionText                                  */
  5. /*              IErrorInfo                                      */
  6. /*              IGUIErrorInfo                                   */
  7. /*              ISystemErrorInfo                                */
  8. /*                                                              */
  9. /* DESCRIPTION:  These classes are used to obtain exception     */
  10. /*               text from a resource file, and error           */
  11. /*               information from the last PM or OS/2 error.    */
  12. /*                                                              */
  13. /*               Hungarian notation is ....                     */
  14. /*                                                              */
  15. /* CHANGE ACTIVITY:                                             */
  16. /* ---------------                                              */
  17. /*   DATE:   INITIAL:   DESCRIPTION:                            */
  18. /*                                                              */
  19. /* 04/09/92    Kevin Leong    Initial Design and Code           */
  20. /* 07/11/92    Bruce Olson    Redesign, add assertion support   */
  21. /*                            and termination model setup.      */
  22. /* 07/26/92    Bruce Olson    Move macros to iexcbase.hpp and   */
  23. /*                            add classes for retrieving info.  */
  24. /* 08/18/92    Bruce Olson    Updated comments..                */
  25. /*                                                              */
  26. /****************************************************************/
  27. /* Copyright (c) IBM Corporation 1992                           */
  28. /****************************************************************/
  29.  
  30. #if !defined( _IBASETYP_ )
  31.   #include <ibasetyp.hpp>
  32. #endif
  33.  
  34. #include <iexcbase.hpp>
  35.  
  36. class IResourceId;
  37.  
  38. /****************************************************************/
  39. /* Class: IExceptionText                                       */
  40. /****************************************************************/
  41. class IExceptionText {
  42. public:
  43.   /****************************************************************/
  44.   /* Constructor to load the exception text from a resource file. */
  45.   /****************************************************************/
  46.                        IExceptionText(const IResourceId& resid);
  47.  
  48.                       ~IExceptionText();
  49.  
  50.   /****************************************************************/
  51.   /* Casting operator to return the exception text.               */
  52.   /****************************************************************/
  53.  operator const char*  () const;
  54.  
  55.   /****************************************************************/
  56.   /* Function to return the exception text.                       */
  57.   /****************************************************************/
  58.           const char*  text() const;
  59.  
  60. private:
  61.                 char*  excTextCl;
  62.                        IExceptionText(const IExceptionText& exctxt);
  63.       IExceptionText&  operator=(const IExceptionText& exctxt);
  64. };
  65.  
  66. /****************************************************************/
  67. /* Class: IErrorInfo - This is a virtual base class.            */
  68. /****************************************************************/
  69. class IErrorInfo {
  70. public:
  71.  
  72.  virtual operator const char*  () const = 0;
  73.           virtual const char*  text() const = 0;
  74.         virtual unsigned long  errorId() const = 0;
  75.               virtual Boolean  isError() const = 0;
  76. };
  77.  
  78.  
  79. /****************************************************************/
  80. /* Class: IGUIErrorInfo                                         */
  81. /****************************************************************/
  82. class IGUIErrorInfo : public IErrorInfo
  83. {
  84. public:
  85.   /****************************************************************/
  86.   /* Constructor to obtain the error information from the last    */
  87.   /* PM error.  If the name of the failing API is passed in, it   */
  88.   /* will be prefixed to the error text.                          */
  89.   /****************************************************************/
  90.                        IGUIErrorInfo(const char* GUIFunctionName = 0);
  91.  
  92.                       ~IGUIErrorInfo();
  93.  
  94.   /****************************************************************/
  95.   /* Casting operator to return the error text.                   */
  96.   /****************************************************************/
  97.  operator const char*  () const;
  98.  
  99.   /****************************************************************/
  100.   /* Function to return the error text.                           */
  101.   /****************************************************************/
  102.           const char*  text() const;
  103.  
  104.   /****************************************************************/
  105.   /* Function to return the error ID.                             */
  106.   /****************************************************************/
  107.         unsigned long  errorId() const;
  108.  
  109.   /****************************************************************/
  110.   /* Function to indicate if the constructor found error          */
  111.   /* information available.                                       */
  112.   /****************************************************************/
  113.               Boolean  isError() const;
  114.  
  115. private:
  116.                 void*  perrinfoCl;
  117.                 char*  pszFuncNameTextCl;
  118.                        IGUIErrorInfo(const IGUIErrorInfo& errinf);
  119.        IGUIErrorInfo&  operator=(const IGUIErrorInfo& errinf);
  120. };
  121.  
  122. /****************************************************************/
  123. /* Class: ISystemErrorInfo                                      */
  124. /****************************************************************/
  125. class ISystemErrorInfo : public IErrorInfo {
  126. public:
  127.   /****************************************************************/
  128.   /* Constructor to obtain the error information from the last    */
  129.   /* OS/2 error.  If the name of the failing API is passed in,    */
  130.   /* it will be prefixed to the error text.                       */
  131.   /****************************************************************/
  132.                        ISystemErrorInfo(unsigned long systemErrorId,
  133.                                         const char* systemFunctionName = 0);
  134.  
  135.                       ~ISystemErrorInfo();
  136.  
  137.   /****************************************************************/
  138.   /* Casting operator to return the error text.                   */
  139.   /****************************************************************/
  140.  operator const char*  () const;
  141.  
  142.   /****************************************************************/
  143.   /* Function to return the error text.                           */
  144.   /****************************************************************/
  145.           const char*  text() const;
  146.  
  147.   /****************************************************************/
  148.   /* Function to return the error ID.                             */
  149.   /****************************************************************/
  150.         unsigned long  errorId() const;
  151.  
  152.   /****************************************************************/
  153.   /* Function to indicate if the constructor found error          */
  154.   /* information available.                                       */
  155.   /****************************************************************/
  156.               Boolean  isError() const;
  157.  
  158. private:
  159.         unsigned long  ulClSystemErrorId;
  160.                 char*  pszClErrorText;
  161.                        ISystemErrorInfo(const ISystemErrorInfo& errinf);
  162.     ISystemErrorInfo&  operator=(const ISystemErrorInfo& errinf);
  163. };
  164.  
  165.  
  166. #endif /* _IEXCEPT_ */
  167.