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.

63 lines
1.8 KiB

  1. //--------------------------------------------------------------------
  2. // ErrorHandling - header
  3. // Copyright (C) Microsoft Corporation, 1999
  4. //
  5. // Created by: Louis Thomas (louisth), 8-10-99
  6. //
  7. // Macro definitions for CertSrv style error handling
  8. //
  9. #ifndef ERROR_HANDLING_H
  10. #define ERROR_HANDLING_H
  11. #define _Verify(expression, hr, label) \
  12. if (!(expression)) { \
  13. wprintf(L"Verify failed: '%ws' is false.\n", L## #expression); \
  14. hr=E_UNEXPECTED; \
  15. goto label; \
  16. }
  17. #define _IgnoreError(hr, errorsource) \
  18. wprintf(L##errorsource L" failed with 0x%08X, ignored.\n", hr);
  19. #define _JumpError(hr, label, errorsource) \
  20. wprintf(L##errorsource L" failed with 0x%08X.\n", hr); \
  21. goto label;
  22. #define _JumpErrorStr(hr, label, errorsource, wstr) \
  23. wprintf(L##errorsource L"(%ws) failed with 0x%08X.\n", wstr, hr); \
  24. goto label;
  25. #define _JumpIfError(hr, label, errorsource) \
  26. if (FAILED(hr)) { \
  27. wprintf(L##errorsource L" failed with 0x%08X.\n", hr); \
  28. goto label; \
  29. }
  30. #define _JumpIfErrorStr(hr, label, errorsource, wstr) \
  31. if (FAILED(hr)) { \
  32. wprintf(L##errorsource L"(%ws) failed with 0x%08X.\n", wstr, hr); \
  33. goto label; \
  34. }
  35. #define _JumpIfOutOfMemory(hr, label, pointer) \
  36. if (NULL==(pointer)) { \
  37. hr=E_OUTOFMEMORY; \
  38. wprintf(L"Out of memory.\n"); \
  39. goto label; \
  40. }
  41. #define _TrapException(hr) \
  42. __except(hr=myHExceptionCode(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) {}
  43. #define _TeardownError(hr, hr2, errorsource) \
  44. if (FAILED(hr2)) { \
  45. wprintf(L##errorsource L" failed with 0x%08X during teardown.\n", hr2); \
  46. if (!FAILED(hr)) { \
  47. hr=hr2; \
  48. } \
  49. }
  50. #endif ERROR_HANDLING_H