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.

70 lines
2.9 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. #if DBG
  13. #define D3D_THROW( hResult, string ) \
  14. { \
  15. char s[_MAX_PATH]; \
  16. _snprintf(s, _MAX_PATH, "*** Exception in %s Line: %d", __FILE__, \
  17. __LINE__); \
  18. D3D_ERR(s); \
  19. if (strcmp(string,"") != 0) \
  20. { \
  21. D3D_ERR(string); \
  22. } \
  23. throw hResult; \
  24. }
  25. #define D3D_THROW_LINE( hResult, string, line, file) \
  26. { \
  27. char s[_MAX_PATH]; \
  28. _snprintf(s, _MAX_PATH, "*** Exception in %s Line: %d", file, \
  29. line); \
  30. D3D_ERR(s); \
  31. D3D_ERR(string); \
  32. throw hResult; \
  33. }
  34. #else
  35. #define D3D_THROW( hResult, string ) \
  36. { \
  37. throw hResult; \
  38. }
  39. #define D3D_THROW_LINE( hResult, string, line, file) \
  40. { \
  41. throw hResult; \
  42. }
  43. #endif
  44. #define D3D_THROW_FAIL(string) D3D_THROW(D3DERR_INVALIDCALL, string)
  45. #define D3D_CATCH catch( HRESULT e ) { return e; }
  46. #define D3D_TRY try
  47. class CD3DException
  48. {
  49. public:
  50. CD3DException(HRESULT res, char *msg, int LineNumber, char* file)
  51. {
  52. error = res;
  53. strcpy(message, msg);
  54. strcpy(this->file, file);
  55. line = LineNumber;
  56. }
  57. char message[128];
  58. char file[_MAX_PATH];
  59. HRESULT error;
  60. int line;
  61. void DebugString();
  62. void Popup();
  63. };
  64. #endif // __D3DEXCEPT_H__