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.

160 lines
3.8 KiB

  1. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. //
  3. // EXCEPT.CPP
  4. //
  5. // Exception classes used by this implementation
  6. //
  7. // Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  8. //
  9. #include <_except.h>
  10. // ========================================================================
  11. //
  12. // CLASS CWin32ExceptionHandler
  13. //
  14. // ------------------------------------------------------------------------
  15. //
  16. // CWin32ExceptionHandler::CWin32ExceptionHandler()
  17. //
  18. // Exception handler constructor. Just installs our exception handler,
  19. // saving off the old one for restoration by the destructor.
  20. //
  21. CWin32ExceptionHandler::CWin32ExceptionHandler()
  22. {
  23. m_pfnOldHandler = _set_se_translator( HandleWin32Exception );
  24. }
  25. // ------------------------------------------------------------------------
  26. //
  27. // CWin32ExceptionHandler::~CWin32ExceptionHandler()
  28. //
  29. // Exception handler destructor. Just restores the exception handler
  30. // we saved off in the constructor.
  31. //
  32. CWin32ExceptionHandler::~CWin32ExceptionHandler()
  33. {
  34. _set_se_translator( m_pfnOldHandler );
  35. }
  36. // ------------------------------------------------------------------------
  37. //
  38. // CWin32ExceptionHandler::HandleWin32Exception()
  39. //
  40. // Our Win32 exception handler. Just stuffs the Win32 exception
  41. // information into a C++ exception object and throws it so we
  42. // can catch it with a regular C++ exception handler.
  43. //
  44. void __cdecl
  45. CWin32ExceptionHandler::HandleWin32Exception( unsigned int code, _EXCEPTION_POINTERS * pep )
  46. {
  47. throw CWin32Exception( code, *pep );
  48. }
  49. // ========================================================================
  50. //
  51. // CLASS CDAVException
  52. //
  53. // ------------------------------------------------------------------------
  54. //
  55. // CDAVException::CDAVException()
  56. //
  57. CDAVException::CDAVException( const char * s ) :
  58. exception(s)
  59. {
  60. #ifdef DBG
  61. //
  62. // When we're attached to a debugger, stop here so that
  63. // the soul who is debugging can actually see where the
  64. // exception is being thrown from before it is thrown.
  65. //
  66. if ( GetPrivateProfileInt( "General", "TrapOnThrow", FALSE, gc_szDbgIni ) )
  67. TrapSz( "Throwing DAV exception. Retry now to catch it." );
  68. #endif
  69. }
  70. #ifdef DBG
  71. // ------------------------------------------------------------------------
  72. //
  73. // CDAVException::DbgTrace()
  74. //
  75. void
  76. CDAVException::DbgTrace() const
  77. {
  78. DebugTrace( "%s\n", what() );
  79. }
  80. #endif
  81. // ------------------------------------------------------------------------
  82. //
  83. // CDAVException::Hresult()
  84. //
  85. HRESULT
  86. CDAVException::Hresult() const
  87. {
  88. return E_FAIL;
  89. }
  90. // ------------------------------------------------------------------------
  91. //
  92. // CDAVException::DwLastError()
  93. //
  94. DWORD
  95. CDAVException::DwLastError() const
  96. {
  97. return ERROR_NOT_ENOUGH_MEMORY; //$ Is there a better default?
  98. }
  99. // ========================================================================
  100. //
  101. // CLASS CHresultException
  102. //
  103. // ------------------------------------------------------------------------
  104. //
  105. // CHresultException::Hresult()
  106. //
  107. HRESULT
  108. CHresultException::Hresult() const
  109. {
  110. return m_hr;
  111. }
  112. // ========================================================================
  113. //
  114. // CLASS CLastErrorException
  115. //
  116. // ------------------------------------------------------------------------
  117. //
  118. // CLastErrorException::DwLastError()
  119. //
  120. DWORD
  121. CLastErrorException::DwLastError() const
  122. {
  123. return m_dwLastError;
  124. }
  125. // ========================================================================
  126. //
  127. // CLASS CWin32Exception
  128. //
  129. #ifdef DBG
  130. // ------------------------------------------------------------------------
  131. //
  132. // CWin32Exception::DbgTrace()
  133. //
  134. void
  135. CWin32Exception::DbgTrace() const
  136. {
  137. DebugTrace( "Win32 exception 0x%08lX at address 0x%08lX\n", m_code, m_ep.ExceptionRecord->ExceptionAddress );
  138. }
  139. #endif