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.

105 lines
3.3 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "except.h"
  4. CExceptionString::CExceptionString(
  5. LPCTSTR pszText
  6. ) : m_pszText(NULL)
  7. {
  8. m_pszText = Dup(pszText);
  9. }
  10. CExceptionString::CExceptionString(
  11. const CExceptionString& rhs
  12. ) : m_pszText(NULL)
  13. {
  14. *this = rhs;
  15. }
  16. CExceptionString&
  17. CExceptionString::operator = (
  18. const CExceptionString& rhs
  19. )
  20. {
  21. if (this != &rhs)
  22. {
  23. delete[] m_pszText;
  24. m_pszText = Dup(rhs.m_pszText);
  25. }
  26. return *this;
  27. }
  28. LPTSTR
  29. CExceptionString::Dup(
  30. LPCTSTR psz
  31. )
  32. {
  33. const size_t cch = lstrlen(psz) + 1;
  34. LPTSTR pszNew = new TCHAR[cch];
  35. lstrcpyn(pszNew, psz, cch);
  36. return pszNew;
  37. }
  38. #if DBG
  39. //
  40. // Don't include these strings in free builds. Since the strings
  41. // aren't localized, they're intended for debug output only.
  42. //
  43. LPCTSTR CMemoryException::m_pszReasons[] = { TEXT("alloc"),
  44. TEXT("overflow"),
  45. TEXT("index"),
  46. TEXT("range"),
  47. TEXT("pointer") };
  48. LPCTSTR CFileException::m_pszReasons[] = { TEXT("create"),
  49. TEXT("read"),
  50. TEXT("write"),
  51. TEXT("diskfull"),
  52. TEXT("access"),
  53. TEXT("device") };
  54. LPCTSTR CSyncException::m_pszReasons[] = { TEXT("create"),
  55. TEXT("timeout"),
  56. TEXT("abandoned") };
  57. LPCTSTR CSyncException::m_pszObjects[] = { TEXT("mutex"),
  58. TEXT("critsect"),
  59. TEXT("semaphore"),
  60. TEXT("event"),
  61. TEXT("thread"),
  62. TEXT("process") };
  63. LPCTSTR CResourceException::m_pszReasons[] = { TEXT("accelerator"),
  64. TEXT("anicursor"),
  65. TEXT("aniicon"),
  66. TEXT("bitmap"),
  67. TEXT("cursor"),
  68. TEXT("dialog"),
  69. TEXT("font"),
  70. TEXT("fontdir"),
  71. TEXT("group_cursor"),
  72. TEXT("group_icon"),
  73. TEXT("icon"),
  74. TEXT("menu"),
  75. TEXT("messagetable"),
  76. TEXT("rcdata"),
  77. TEXT("string"),
  78. TEXT("version") };
  79. LPCTSTR
  80. CResourceException::ReasonText(
  81. void
  82. ) const
  83. {
  84. static TCHAR szMsg[MAX_PATH];
  85. wnsprintf(szMsg, ARRAYSIZE(szMsg), TEXT("%s (id: %d)"), m_pszReasons[Type()], m_uResId );
  86. return szMsg;
  87. }
  88. #endif // DBG