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.

111 lines
1.7 KiB

  1. #pragma once
  2. // Exception to be thrown if the process is canceled by the user
  3. class CCancelException
  4. {
  5. };
  6. // Base exception class
  7. /////////////////////////////////////////////////////////////////////////////
  8. class CBaseException
  9. {
  10. protected:
  11. enum
  12. {
  13. MaxErrorBuff = 2 * 1024, // Buffer for formating string messages
  14. };
  15. protected:
  16. CBaseException(){}
  17. public:
  18. CBaseException( UINT nResID, DWORD dwCode = ::GetLastError() )
  19. {
  20. FormatError( nResID, dwCode );
  21. }
  22. CBaseException( LPCWSTR wszError, DWORD dwCode = ::GetLastError() )
  23. {
  24. FormatError( wszError, dwCode );
  25. }
  26. LPCWSTR GetDescription()const{ return m_strError.c_str(); }
  27. protected:
  28. void FormatError( UINT nResID, DWORD dwCode );
  29. void FormatError( LPCWSTR wszError, DWORD dwCode );
  30. private:
  31. std::wstring m_strError;
  32. };
  33. // CObjectException - exception on object access/acquire
  34. class CObjectException : public CBaseException
  35. {
  36. public:
  37. CObjectException( UINT nResID, LPCWSTR wszObject, DWORD dwCode = ::GetLastError() );
  38. CObjectException( UINT nResID,
  39. LPCWSTR wszObject1,
  40. LPCWSTR wszObject2,
  41. DWORD dwCode = ::GetLastError() );
  42. };
  43. // CUnexpectedException - exception that is not expected to normally ocure
  44. /*CUnexpectedException( char* file , UINT nLine, HRESULT hr = S_OK )
  45. {
  46. WCHAR wszBuffer[ CBaseException::MaxErrorBuff ];
  47. try
  48. {
  49. USES_CONVERSION;
  50. ::swprintf( wszBuffer,
  51. L"Unexpected exception occured.\nFile: '%s'.\nLine: %d\nCode: %x",
  52. A2W( file ),
  53. nLine,
  54. hr );
  55. }
  56. catch(...)
  57. {
  58. // A2W exceptions
  59. }
  60. CBaseException::FormatError( wszBuffer, hr );
  61. }
  62. };*/