aboutsummaryrefslogtreecommitdiff
path: root/src/test/DUtilUnitTest/error.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-07-12 17:07:55 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-07-12 17:16:16 +1000
commitdc558da002794cc07013e8376f3c55c73391aa0e (patch)
treefaba96f981f1ea0c6888b387cf43cc78d0bc2927 /src/test/DUtilUnitTest/error.cpp
parentaeddc77fc021f11f68a4c1a093eabf9776866b80 (diff)
downloadwix-dc558da002794cc07013e8376f3c55c73391aa0e.tar.gz
wix-dc558da002794cc07013e8376f3c55c73391aa0e.tar.bz2
wix-dc558da002794cc07013e8376f3c55c73391aa0e.zip
Update Dutil_TraceErrorSource to filter based on the report level.
Diffstat (limited to 'src/test/DUtilUnitTest/error.cpp')
-rw-r--r--src/test/DUtilUnitTest/error.cpp26
1 files changed, 26 insertions, 0 deletions
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 @@
1// 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.
2
3#include "precomp.h"
4
5const int ERROR_STRING_BUFFER = 1024;
6
7static char szMsg[ERROR_STRING_BUFFER];
8static WCHAR wzMsg[ERROR_STRING_BUFFER];
9
10void CALLBACK DutilTestTraceError(
11 __in_z LPCSTR /*szFile*/,
12 __in int /*iLine*/,
13 __in REPORT_LEVEL /*rl*/,
14 __in UINT source,
15 __in HRESULT hrError,
16 __in_z __format_string LPCSTR szFormat,
17 __in va_list args
18 )
19{
20 if (DUTIL_SOURCE_EXTERNAL == source)
21 {
22 ::StringCchPrintfA(szMsg, countof(szMsg), szFormat, args);
23 MultiByteToWideChar(CP_ACP, 0, szMsg, -1, wzMsg, countof(wzMsg));
24 throw gcnew System::Exception(System::String::Format("hr = 0x{0:X8}, message = {1}", hrError, gcnew System::String(wzMsg)));
25 }
26}