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.

136 lines
2.8 KiB

  1. #ifndef _EXCEPT_H_
  2. #define _EXCEPT_H_
  3. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. //
  5. // EXCEPT.H
  6. //
  7. // Exception classes used by this implementation
  8. //
  9. // Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  10. //
  11. #include <stdexcpt.h>
  12. #include <eh.h>
  13. #include <caldbg.h> // For gc_szDbgIni definition
  14. // ------------------------------------------------------------------------
  15. //
  16. // CLASS CWin32ExceptionHandler
  17. //
  18. // Handles Win32 exceptions (access violations, alignment faults, etc.)
  19. // by constructing a C++ exception from information in the Win32 SEH
  20. // exception record and throwing it.
  21. //
  22. class CWin32ExceptionHandler
  23. {
  24. _se_translator_function m_pfnOldHandler;
  25. static void __cdecl HandleWin32Exception( unsigned int, struct _EXCEPTION_POINTERS * );
  26. public:
  27. CWin32ExceptionHandler();
  28. ~CWin32ExceptionHandler();
  29. };
  30. // ------------------------------------------------------------------------
  31. //
  32. // CLASS CDAVException
  33. //
  34. class CDAVException : public exception
  35. {
  36. public:
  37. // CREATORS
  38. //
  39. CDAVException( const char * s = "DAV fatal error exception" );
  40. // ACCESSORS
  41. //
  42. #ifdef DBG
  43. virtual void DbgTrace() const;
  44. #else
  45. void DbgTrace() const {}
  46. #endif
  47. // ACCESSORS
  48. //
  49. virtual HRESULT Hresult() const;
  50. virtual DWORD DwLastError() const;
  51. };
  52. // ------------------------------------------------------------------------
  53. //
  54. // CLASS CHresultException
  55. //
  56. class CHresultException : public CDAVException
  57. {
  58. HRESULT m_hr;
  59. public:
  60. CHresultException( HRESULT hr, const char * s = "HRESULT exception" ) :
  61. CDAVException(s),
  62. m_hr(hr)
  63. {
  64. }
  65. virtual HRESULT Hresult() const;
  66. };
  67. // ------------------------------------------------------------------------
  68. //
  69. // CLASS CLastErrorException
  70. //
  71. class CLastErrorException : public CDAVException
  72. {
  73. DWORD m_dwLastError;
  74. public:
  75. CLastErrorException( const char * s = "LastError exception" ) :
  76. CDAVException(s),
  77. m_dwLastError(GetLastError())
  78. {
  79. }
  80. virtual DWORD DwLastError() const;
  81. };
  82. // ------------------------------------------------------------------------
  83. //
  84. // CLASS CWin32Exception
  85. //
  86. // This exception is thrown as a result of any Win32 exception
  87. // (access violation, alignment fault, etc.) By catching it
  88. // you can better determine what happened.
  89. //
  90. class CWin32Exception : public CDAVException
  91. {
  92. unsigned int m_code;
  93. const struct _EXCEPTION_POINTERS& m_ep;
  94. // NOT IMPLEMENTED
  95. //
  96. CWin32Exception& operator=( const CWin32Exception& );
  97. public:
  98. // CREATORS
  99. //
  100. CWin32Exception( unsigned int code, const struct _EXCEPTION_POINTERS& ep ) :
  101. CDAVException(),
  102. m_code(code),
  103. m_ep(ep)
  104. {
  105. }
  106. // ACCESSORS
  107. //
  108. #ifdef DBG
  109. virtual void DbgTrace() const;
  110. #endif
  111. };
  112. #endif // !defined(_EXCEPT_H_)