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.

79 lines
1.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // tracex.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Defines the C++ portion of the trace API.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 08/20/1998 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #include <ias.h>
  19. #include <exception>
  20. //////////
  21. // We want this to compile correctly in a retail build.
  22. //////////
  23. #ifdef IASTraceExcept
  24. #undef IASTraceExcept
  25. #endif
  26. #ifdef IASTracePrintf
  27. #undef IASTracePrintf
  28. #endif
  29. #ifdef IASTraceString
  30. #undef IASTraceString
  31. #endif
  32. VOID
  33. WINAPIV
  34. IASTracePrintf(
  35. IN PCSTR szFormat,
  36. ...
  37. );
  38. VOID
  39. WINAPI
  40. IASTraceString(
  41. IN PCSTR szString
  42. );
  43. VOID
  44. WINAPI
  45. IASTraceExcept( VOID )
  46. {
  47. try
  48. {
  49. throw;
  50. }
  51. catch (const std::exception& x)
  52. {
  53. IASTracePrintf("Caught standard exception: %s", x.what());
  54. }
  55. catch (const _com_error& ce)
  56. {
  57. CHAR szMessage[256];
  58. DWORD nChar = IASFormatSysErr(
  59. ce.Error(),
  60. szMessage,
  61. sizeof(szMessage)
  62. );
  63. szMessage[nChar] = '\0';
  64. IASTracePrintf("Caught COM exception: %s", szMessage);
  65. }
  66. catch (...)
  67. {
  68. IASTraceString("Caught unknown exception");
  69. }
  70. }