From dc558da002794cc07013e8376f3c55c73391aa0e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 12 Jul 2020 17:07:55 +1000 Subject: Update Dutil_TraceErrorSource to filter based on the report level. --- src/test/DUtilUnitTest/error.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/DUtilUnitTest/error.cpp (limited to 'src/test/DUtilUnitTest/error.cpp') diff --git a/src/test/DUtilUnitTest/error.cpp b/src/test/DUtilUnitTest/error.cpp new file mode 100644 index 00000000..e51971c3 --- /dev/null +++ b/src/test/DUtilUnitTest/error.cpp @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +const int ERROR_STRING_BUFFER = 1024; + +static char szMsg[ERROR_STRING_BUFFER]; +static WCHAR wzMsg[ERROR_STRING_BUFFER]; + +void CALLBACK DutilTestTraceError( + __in_z LPCSTR /*szFile*/, + __in int /*iLine*/, + __in REPORT_LEVEL /*rl*/, + __in UINT source, + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + if (DUTIL_SOURCE_EXTERNAL == source) + { + ::StringCchPrintfA(szMsg, countof(szMsg), szFormat, args); + MultiByteToWideChar(CP_ACP, 0, szMsg, -1, wzMsg, countof(wzMsg)); + throw gcnew System::Exception(System::String::Format("hr = 0x{0:X8}, message = {1}", hrError, gcnew System::String(wzMsg))); + } +} -- cgit v1.2.3-55-g6feb