Source code of Windows XP (NT5)
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.

104 lines
3.2 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. LPTSTR pszNew = new TCHAR[lstrlen(psz) + 1];
  34. lstrcpy(pszNew, psz);
  35. return pszNew;
  36. }
  37. #if DBG
  38. //
  39. // Don't include these strings in free builds. Since the strings
  40. // aren't localized, they're intended for debug output only.
  41. //
  42. LPCTSTR CMemoryException::m_pszReasons[] = { TEXT("alloc"),
  43. TEXT("overflow"),
  44. TEXT("index"),
  45. TEXT("range"),
  46. TEXT("pointer") };
  47. LPCTSTR CFileException::m_pszReasons[] = { TEXT("create"),
  48. TEXT("read"),
  49. TEXT("write"),
  50. TEXT("diskfull"),
  51. TEXT("access"),
  52. TEXT("device") };
  53. LPCTSTR CSyncException::m_pszReasons[] = { TEXT("create"),
  54. TEXT("timeout"),
  55. TEXT("abandoned") };
  56. LPCTSTR CSyncException::m_pszObjects[] = { TEXT("mutex"),
  57. TEXT("critsect"),
  58. TEXT("semaphore"),
  59. TEXT("event"),
  60. TEXT("thread"),
  61. TEXT("process") };
  62. LPCTSTR CResourceException::m_pszReasons[] = { TEXT("accelerator"),
  63. TEXT("anicursor"),
  64. TEXT("aniicon"),
  65. TEXT("bitmap"),
  66. TEXT("cursor"),
  67. TEXT("dialog"),
  68. TEXT("font"),
  69. TEXT("fontdir"),
  70. TEXT("group_cursor"),
  71. TEXT("group_icon"),
  72. TEXT("icon"),
  73. TEXT("menu"),
  74. TEXT("messagetable"),
  75. TEXT("rcdata"),
  76. TEXT("string"),
  77. TEXT("version") };
  78. LPCTSTR
  79. CResourceException::ReasonText(
  80. void
  81. ) const
  82. {
  83. static TCHAR szMsg[MAX_PATH];
  84. wsprintf(szMsg, TEXT("%s (id: %d)"), m_pszReasons[Type()], m_uResId );
  85. return szMsg;
  86. }
  87. #endif // DBG