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.

228 lines
6.6 KiB

  1. /*****************************************************************************
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. ShowError.CPP
  5. Abstract:
  6. This module is intended to prepare error messages.
  7. Author:
  8. Akhil Gokhale 03-Oct.-2000 (Created it)
  9. Revision History:
  10. ******************************************************************************/
  11. #include "pch.h"
  12. #include "ETCommon.h"
  13. #include "ShowError.h"
  14. #include "resource.h"
  15. CShowError::CShowError()
  16. /*++
  17. Routine Description:
  18. Class default constructor.
  19. Arguments:
  20. None
  21. Return Value:
  22. None
  23. --*/
  24. {
  25. m_lErrorNumber = 0;
  26. }
  27. CShowError::CShowError(
  28. IN LONG lErrorNumber
  29. )
  30. /*++
  31. Routine Description:
  32. Class constructor.
  33. Arguments:
  34. IN lError?Number : Error Number
  35. Return Value:
  36. None
  37. --*/
  38. {
  39. m_lErrorNumber = lErrorNumber;
  40. }
  41. CShowError::~CShowError()
  42. /*++
  43. Routine Description:
  44. Class default desctructor.
  45. Arguments:
  46. None
  47. Return Value:
  48. None
  49. --*/
  50. {
  51. }
  52. LPCTSTR CShowError::ShowReason()
  53. /*++
  54. Routine Description:
  55. This function will return Text reason for given error code.
  56. Arguments:
  57. None
  58. Return Value:
  59. None
  60. --*/
  61. {
  62. WCHAR szTempStr[MAX_RES_STRING];
  63. BOOL bShowExtraMsg = TRUE;
  64. SecureZeroMemory(szTempStr,sizeof(WCHAR)*MAX_RES_STRING);
  65. DEBUG_INFO;
  66. switch(m_lErrorNumber )
  67. {
  68. case MK_E_SYNTAX:
  69. case E_OUTOFMEMORY:
  70. {
  71. StringCopy(m_szErrorMsg,GetReason(),
  72. SIZE_OF_ARRAY(m_szErrorMsg));
  73. bShowExtraMsg = FALSE;
  74. }
  75. break;
  76. case IDS_USERNAME_REQUIRED:
  77. StringCopy(m_szErrorMsg,GetResString(IDS_USERNAME_REQUIRED),
  78. SIZE_OF_ARRAY(m_szErrorMsg));
  79. g_dwOptionFlag = FALSE;
  80. break;
  81. case IDS_ERROR_USERNAME_EMPTY:
  82. StringCopy(m_szErrorMsg,GetResString(IDS_ERROR_USERNAME_EMPTY),
  83. SIZE_OF_ARRAY(m_szErrorMsg));
  84. g_dwOptionFlag = FALSE;
  85. break;
  86. case IDS_ERROR_SERVERNAME_EMPTY:
  87. StringCopy(m_szErrorMsg,
  88. GetResString(IDS_ERROR_SERVERNAME_EMPTY),
  89. SIZE_OF_ARRAY(m_szErrorMsg));
  90. g_dwOptionFlag = FALSE;
  91. break;
  92. case IDS_ID_TRIG_NAME_MISSING:
  93. StringCopy(m_szErrorMsg,GetResString(IDS_ID_TRIG_NAME_MISSING),
  94. SIZE_OF_ARRAY(m_szErrorMsg));
  95. break;
  96. case IDS_ID_TYPE_SOURCE:
  97. StringCopy(m_szErrorMsg,GetResString(IDS_ID_TYPE_SOURCE),
  98. SIZE_OF_ARRAY(m_szErrorMsg));
  99. break;
  100. case IDS_INVALID_ID:
  101. StringCopy(m_szErrorMsg,GetResString(IDS_INVALID_ID),
  102. SIZE_OF_ARRAY(m_szErrorMsg));
  103. g_dwOptionFlag = FALSE;
  104. break;
  105. case IDS_ID_TK_NAME_MISSING:
  106. StringCopy(m_szErrorMsg,GetResString(IDS_ID_TK_NAME_MISSING),
  107. SIZE_OF_ARRAY(m_szErrorMsg));
  108. break;
  109. case IDS_ID_REQUIRED:
  110. StringCopy(m_szErrorMsg,GetResString(IDS_ID_REQUIRED),
  111. SIZE_OF_ARRAY(m_szErrorMsg));
  112. break;
  113. case IDS_ID_NON_NUMERIC:
  114. StringCopy(m_szErrorMsg,GetResString(IDS_ID_NON_NUMERIC),
  115. SIZE_OF_ARRAY(m_szErrorMsg));
  116. g_dwOptionFlag = FALSE;
  117. break;
  118. case IDS_HEADER_NOT_ALLOWED:
  119. StringCopy(m_szErrorMsg,GetResString(IDS_HEADER_NOT_ALLOWED),
  120. SIZE_OF_ARRAY(m_szErrorMsg));
  121. break;
  122. case IDS_ERROR_USERNAME_BUT_NOMACHINE:
  123. StringCopy(m_szErrorMsg,
  124. GetResString(IDS_ERROR_USERNAME_BUT_NOMACHINE),
  125. SIZE_OF_ARRAY(m_szErrorMsg));
  126. bShowExtraMsg = FALSE;
  127. break;
  128. case IDS_ID_SOURCE_EMPTY:
  129. StringCopy(m_szErrorMsg,GetResString(IDS_ID_SOURCE_EMPTY),
  130. SIZE_OF_ARRAY(m_szErrorMsg));
  131. g_dwOptionFlag = FALSE;
  132. break;
  133. case IDS_ID_DESC_EMPTY:
  134. StringCopy(m_szErrorMsg,GetResString(IDS_ID_DESC_EMPTY),
  135. SIZE_OF_ARRAY(m_szErrorMsg));
  136. g_dwOptionFlag = FALSE;
  137. break;
  138. case IDS_ID_LOG_EMPTY:
  139. StringCopy(m_szErrorMsg,GetResString(IDS_ID_LOG_EMPTY),
  140. SIZE_OF_ARRAY(m_szErrorMsg));
  141. g_dwOptionFlag = FALSE;
  142. break;
  143. case IDS_ID_INVALID_TRIG_NAME:
  144. StringCopy(m_szErrorMsg,GetResString(IDS_ID_INVALID_TRIG_NAME),
  145. SIZE_OF_ARRAY(m_szErrorMsg));
  146. g_dwOptionFlag = FALSE;
  147. break;
  148. case IDS_RUN_AS_USERNAME_REQUIRED:
  149. StringCopy(m_szErrorMsg,
  150. GetResString(IDS_RUN_AS_USERNAME_REQUIRED),
  151. SIZE_OF_ARRAY(m_szErrorMsg));
  152. g_dwOptionFlag = FALSE;
  153. break;
  154. case IDS_INVALID_RANGE:
  155. StringCopy(m_szErrorMsg,
  156. GetResString(IDS_INVALID_RANGE),
  157. SIZE_OF_ARRAY(m_szErrorMsg));
  158. g_dwOptionFlag = FALSE;
  159. break;
  160. case IDS_ERROR_R_U_EMPTY:
  161. StringCopy(m_szErrorMsg,GetResString(IDS_ERROR_R_U_EMPTY),
  162. SIZE_OF_ARRAY(m_szErrorMsg));
  163. g_dwOptionFlag = FALSE;
  164. case IDS_TRIGGER_ID_NON_ZERO:
  165. StringCopy(m_szErrorMsg,GetResString(IDS_TRIGGER_ID_NON_ZERO),
  166. SIZE_OF_ARRAY(m_szErrorMsg));
  167. g_dwOptionFlag = FALSE;
  168. default:
  169. break;
  170. }
  171. if(bShowExtraMsg)
  172. {
  173. WCHAR szStr[64];
  174. SecureZeroMemory(szStr, sizeof(WCHAR)*64);
  175. StringCopy(szStr,GetResString(IDS_UTILITY_NAME),SIZE_OF_ARRAY(szStr));
  176. switch(g_dwOptionFlag)
  177. {
  178. case 0:
  179. StringCopy(szTempStr,L"",SIZE_OF_ARRAY(szTempStr));
  180. break;
  181. case 1:
  182. StringCchPrintfW(szTempStr,SIZE_OF_ARRAY(szTempStr),
  183. GetResString(IDS_TYPE_HELP),szStr,szCreateOption);
  184. break;
  185. case 2:
  186. StringCchPrintfW(szTempStr,SIZE_OF_ARRAY(szTempStr),
  187. GetResString(IDS_TYPE_HELP),szStr,szDeleteOption);
  188. break;
  189. case 3:
  190. StringCchPrintfW(szTempStr,SIZE_OF_ARRAY(szTempStr),
  191. GetResString(IDS_TYPE_HELP),szStr,szQueryOption);
  192. break;
  193. default:
  194. break;
  195. }
  196. }
  197. StringConcat(m_szErrorMsg,szTempStr,SIZE_OF_ARRAY(m_szErrorMsg));
  198. DEBUG_INFO;
  199. return m_szErrorMsg;
  200. }