Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
4.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ExcOper.h
  7. //
  8. // Abstract:
  9. // Definition of the exception classes.
  10. //
  11. // Author:
  12. // David Potter (davidp) May 20, 1996
  13. //
  14. // Implementation File:
  15. // ExcOper.cpp
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _EXCOPER_H_
  23. #define _EXCOPER_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Include Files
  26. /////////////////////////////////////////////////////////////////////////////
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Forward Class Declarations
  29. /////////////////////////////////////////////////////////////////////////////
  30. class CExceptionWithOper;
  31. class CNTException;
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Type Definitions
  34. /////////////////////////////////////////////////////////////////////////////
  35. typedef DWORD SC;
  36. #define EXCEPT_MAX_OPER_ARG_LENGTH 260
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CExceptionWithOper
  39. /////////////////////////////////////////////////////////////////////////////
  40. class CExceptionWithOper : public CException
  41. {
  42. // abstract class for dynamic type checking
  43. DECLARE_DYNAMIC(CExceptionWithOper)
  44. public:
  45. // Constructors
  46. CExceptionWithOper(
  47. IN IDS idsOperation,
  48. IN LPCTSTR pszOperArg1 = NULL,
  49. IN LPCTSTR pszOperArg2 = NULL
  50. );
  51. CExceptionWithOper(
  52. IN IDS idsOperation,
  53. IN LPCTSTR pszOperArg1,
  54. IN LPCTSTR pszOperArg2,
  55. IN BOOL bAutoDelete
  56. );
  57. // Operations
  58. public:
  59. virtual BOOL GetErrorMessage(
  60. LPTSTR lpszError,
  61. UINT nMaxError,
  62. PUINT pnHelpContext = NULL
  63. );
  64. virtual int ReportError(
  65. UINT nType = MB_OK,
  66. UINT nError = 0
  67. );
  68. void SetOperation(
  69. IN IDS idsOperation,
  70. IN LPCTSTR pszOperArg1,
  71. IN LPCTSTR pszOperArg2
  72. );
  73. void FormatWithOperation(
  74. OUT LPTSTR lpszError,
  75. IN UINT nMaxError,
  76. IN LPCTSTR pszMsg
  77. );
  78. // Implementation
  79. public:
  80. virtual ~CExceptionWithOper(void);
  81. protected:
  82. IDS m_idsOperation;
  83. TCHAR m_szOperArg1[EXCEPT_MAX_OPER_ARG_LENGTH];
  84. TCHAR m_szOperArg2[EXCEPT_MAX_OPER_ARG_LENGTH];
  85. public:
  86. IDS IdsOperation(void) { return m_idsOperation; }
  87. LPTSTR PszOperArg1(void) { return m_szOperArg1; }
  88. LPTSTR PszOperArg2(void) { return m_szOperArg2; }
  89. }; //*** class CExceptionWithOper
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CNTException
  92. /////////////////////////////////////////////////////////////////////////////
  93. class CNTException : public CExceptionWithOper
  94. {
  95. // abstract class for dynamic type checking
  96. DECLARE_DYNAMIC(CNTException)
  97. public:
  98. // Constructors
  99. CNTException(
  100. IN SC sc,
  101. IN IDS idsOperation = NULL,
  102. IN LPCTSTR pszOperArg1 = NULL,
  103. IN LPCTSTR pszOperArg2 = NULL
  104. );
  105. CNTException(
  106. IN SC sc,
  107. IN IDS idsOperation,
  108. IN LPCTSTR pszOperArg1,
  109. IN LPCTSTR pszOperArg2,
  110. IN BOOL bAutoDelete
  111. );
  112. // Operations
  113. public:
  114. virtual BOOL GetErrorMessage(
  115. LPTSTR lpszError,
  116. UINT nMaxError,
  117. PUINT pnHelpContext = NULL
  118. );
  119. void SetOperation(
  120. IN SC sc,
  121. IN IDS idsOperation,
  122. IN LPCTSTR pszOperArg1,
  123. IN LPCTSTR pszOperArg2
  124. )
  125. {
  126. m_sc = sc;
  127. CExceptionWithOper::SetOperation(idsOperation, pszOperArg1, pszOperArg2);
  128. }
  129. // Implementation
  130. public:
  131. virtual ~CNTException(void);
  132. protected:
  133. SC m_sc;
  134. public:
  135. SC Sc(void) { return m_sc; }
  136. }; //*** class CNTException
  137. /////////////////////////////////////////////////////////////////////////////
  138. // Global Functions
  139. /////////////////////////////////////////////////////////////////////////////
  140. void ThrowStaticException(
  141. IN IDS idsOperation = NULL,
  142. IN LPCTSTR pszOperArg1 = NULL,
  143. IN LPCTSTR pszOperArg2 = NULL
  144. );
  145. void ThrowStaticException(
  146. IN SC sc,
  147. IN IDS idsOperation = NULL,
  148. IN LPCTSTR pszOperArg1 = NULL,
  149. IN LPCTSTR pszOperArg2 = NULL
  150. );
  151. /////////////////////////////////////////////////////////////////////////////
  152. #endif // _CAEXCEPT_H_