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.

58 lines
2.3 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3dexcept.h
  6. * Content: Exception support
  7. *
  8. ***************************************************************************/
  9. #ifndef __D3DEXCEPT_H__
  10. #define __D3DEXCEPT_H__
  11. #include <string.h>
  12. #define D3D_THROW( hResult, string ) \
  13. { \
  14. char s[_MAX_PATH]; \
  15. _snprintf(s, _MAX_PATH, "*** Exception in %s Line: %d", __FILE__, \
  16. __LINE__); \
  17. D3D_ERR(s); \
  18. if (strcmp(string,"") != 0) \
  19. { \
  20. D3D_ERR(string); \
  21. } \
  22. throw hResult; \
  23. }
  24. #define D3D_THROW_LINE( hResult, string, line, file) \
  25. { \
  26. char s[_MAX_PATH]; \
  27. _snprintf(s, _MAX_PATH, "*** Exception in %s Line: %d", file, \
  28. line); \
  29. D3D_ERR(s); \
  30. D3D_ERR(string); \
  31. throw hResult; \
  32. }
  33. #define D3D_THROW_FAIL(string) D3D_THROW(D3DERR_INVALIDCALL, string)
  34. #define D3D_CATCH catch( HRESULT e ) { return e; }
  35. #define D3D_TRY try
  36. class CD3DException
  37. {
  38. public:
  39. CD3DException(HRESULT res, char *msg, int LineNumber, char* file)
  40. {
  41. error = res;
  42. strcpy(message, msg);
  43. strcpy(this->file, file);
  44. line = LineNumber;
  45. }
  46. char message[128];
  47. char file[_MAX_PATH];
  48. HRESULT error;
  49. int line;
  50. void DebugString();
  51. void Popup();
  52. };
  53. #endif // __D3DEXCEPT_H__