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.

66 lines
1.8 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dxexcp.h
  6. * Content: Definition of the DirectXException class
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 07/16/99 rodtoll Created
  12. * 11/12/99 rodtoll Aded include for tchar, required.
  13. *
  14. ***************************************************************************/
  15. #ifndef __DIRECTXEXCEPTION_H
  16. #define __DIRECTXEXCEPTION_H
  17. // These constants are used by the DirectX Exception class.
  18. //
  19. const unsigned int cMaxFuncLength = 100;
  20. const unsigned int cMaxErrorLength = 100;
  21. // DirectXException
  22. //
  23. // This class is the exception class for handling exceptions from
  24. // errors from DirectX libraries. It is used as the base class
  25. // for the various DirectX exceptions. (E.g. DirectSoundException).
  26. //
  27. class DirectXException: public exception
  28. {
  29. public:
  30. DirectXException( const TCHAR *funcName, HRESULT result, const unsigned int moduleID = 0, unsigned int lineNumber = 0 )
  31. {
  32. _tcscpy( m_szFunctionName, funcName );
  33. m_uiModuleID = moduleID;
  34. m_uiLineNumber = lineNumber;
  35. m_result = result;
  36. MapResultToString();
  37. }
  38. DirectXException( const DirectXException &except )
  39. {
  40. m_result = except.m_result;
  41. m_uiModuleID = except.m_uiModuleID;
  42. _tcscpy( m_szFunctionName, except.m_szFunctionName );
  43. _tcscpy( m_szErrorString, except.m_szErrorString );
  44. }
  45. virtual const TCHAR *what()
  46. {
  47. return m_szErrorString;
  48. }
  49. unsigned int m_uiLineNumber;
  50. unsigned int m_uiModuleID;
  51. HRESULT m_result;
  52. TCHAR m_szFunctionName[cMaxFuncLength];
  53. TCHAR m_szErrorString[cMaxErrorLength];
  54. protected:
  55. virtual void MapResultToString( ) {};
  56. };
  57. #endif