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.

71 lines
1.3 KiB

  1. // Copyright (c) 1995 - 1996 Microsoft Corporation. All Rights Reserved.
  2. //
  3. // hrExcept.h
  4. //
  5. #ifndef __HREXCEPT__
  6. #define __HREXCEPT__
  7. // A hierarchy of classes intended to be used
  8. // as exceptions.
  9. // Based around the common HRESULT error code.
  10. //
  11. // CHRESULTException
  12. //
  13. // the root exception. the HRESULT stored provides more
  14. // information as to why the exception was thrown
  15. class CHRESULTException {
  16. public:
  17. CHRESULTException(const HRESULT hrReason = E_FAIL) { m_hrReason = hrReason; }
  18. HRESULT Reason(void) const { return m_hrReason; }
  19. private:
  20. HRESULT m_hrReason; // the reason for throwing the exception
  21. };
  22. //
  23. // The following sub classes are provided as short cuts for their respective
  24. // HRESULT codes.
  25. //
  26. // CE_OUTOFMEMORY
  27. //
  28. class CE_OUTOFMEMORY : public CHRESULTException {
  29. public:
  30. CE_OUTOFMEMORY() : CHRESULTException(E_OUTOFMEMORY) {}
  31. };
  32. //
  33. // CE_UNEXPECTED
  34. //
  35. class CE_UNEXPECTED : public CHRESULTException {
  36. public:
  37. CE_UNEXPECTED() : CHRESULTException(E_UNEXPECTED) {}
  38. };
  39. //
  40. // CE_FAIL
  41. //
  42. class CE_FAIL : public CHRESULTException {
  43. public:
  44. CE_FAIL() : CHRESULTException(E_FAIL) {}
  45. };
  46. //
  47. // CE_INVALIDARG
  48. //
  49. class CE_INVALIDARG : public CHRESULTException {
  50. public:
  51. CE_INVALIDARG() : CHRESULTException(E_INVALIDARG) {}
  52. };
  53. #endif // __HREXCEPT__