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.

44 lines
1.6 KiB

  1. /* Jason's error handling macros */
  2. #ifndef fRetErr_h
  3. #define fRetErr_h
  4. #ifdef _DEBUG
  5. FARINTERNAL_(void) wWarn (LPSTR sz, LPSTR szFile, int iLine);
  6. #define Warn(sz) wWarn(sz,_szAssertFile,__LINE__)
  7. #else
  8. #define Warn(sz)
  9. #endif // _DEBUG
  10. // Call x. If hresult is not NOERROR, goto errRtn.
  11. #define ErrRtn(x) do {if (NOERROR != (x)) {Warn(NULL); goto errRtn;}} while (0)
  12. // Call x. If hresult is not NOERROR, store it in hresult and goto errRtn.
  13. #define ErrRtnH(x) do {if (NOERROR != (hresult=(x))) {Warn(NULL); goto errRtn;}} while (0)
  14. // If x, goto errRtn.
  15. #define ErrNz(x) do {if (x) {Warn(NULL); goto errRtn;}} while (0)
  16. // If x==0, goto errRtn.
  17. #define ErrZ(x) do {if (!(x)) {Warn(NULL); goto errRtn;}} while (0)
  18. // If x==0, goto errRtn with a specific scode
  19. #define ErrZS(x, scode) do {if (!(x)) {Warn(NULL); hresult=ResultFromScode(scode); goto errRtn;}} while (0)
  20. // Call x. If hresult is not NOERROR, return that hresult.
  21. #define RetErr(x) do {HRESULT hresult; if (NOERROR != (hresult=(x))) {Warn(NULL); return hresult;}} while (0)
  22. // Return unexpected error if x is non-zero
  23. #define RetNz(x) do {if (x) {AssertSz(0,#x); return ReportResult(0, E_UNEXPECTED, 0, 0);}} while (0)
  24. // Return specific scode if x is non-zero
  25. #define RetNzS(x, scode) do {if (x) {Warn(NULL); return ResultFromScode (scode);}} while (0)
  26. // Return unexpected error if x is zero
  27. #define RetZ(x) do {if (!(x)) {AssertSz(0,#x); return ReportResult(0, E_UNEXPECTED, 0, 0);}} while (0)
  28. // Return specific scode if x is zero
  29. #define RetZS(x, scode) do {if (!(x)) {Warn(NULL); return ResultFromScode (scode);}} while (0)
  30. #endif