diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-06-22 19:06:48 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-06-24 20:23:44 +1000 |
commit | 7fc25bc32547277c38bbedceb39c454843af8aac (patch) | |
tree | ddc28b69bc4d39a15fd788069a5d8a0f903a0ad4 /src/dutil/inc/conutil.h | |
parent | 57536725e6061c7f6cd0f532c07beca7cd1228c9 (diff) | |
download | wix-7fc25bc32547277c38bbedceb39c454843af8aac.tar.gz wix-7fc25bc32547277c38bbedceb39c454843af8aac.tar.bz2 wix-7fc25bc32547277c38bbedceb39c454843af8aac.zip |
Replace ExitTrace with new DUTIL_CALLBACK_TRACEERROR callback.
This allows capturing internal dutil errors and eventually supports filtering to certain parts of dutil.
Add Exit...Source macros to simplify calling both TraceError/TraceErrorDebug and Dutil_TraceErrorSource.
Make existing Exit macros call the new Exit...Source macros so the logic is in one place.
Diffstat (limited to 'src/dutil/inc/conutil.h')
-rw-r--r-- | src/dutil/inc/conutil.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/dutil/inc/conutil.h b/src/dutil/inc/conutil.h index a098cd4c..5f611d01 100644 --- a/src/dutil/inc/conutil.h +++ b/src/dutil/inc/conutil.h | |||
@@ -6,13 +6,19 @@ | |||
6 | extern "C" { | 6 | extern "C" { |
7 | #endif | 7 | #endif |
8 | 8 | ||
9 | #define ConsoleExitOnFailure(x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 9 | #define ConsoleExitOnFailureSource(d, x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
10 | #define ConsoleExitOnLastError(x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } } | 10 | #define ConsoleExitOnLastErrorSource(d, x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } |
11 | #define ConsoleExitOnNull(p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 11 | #define ConsoleExitOnNullSource(d, p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
12 | #define ConsoleExitOnNullWithLastError(p, x, c, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 12 | #define ConsoleExitOnNullWithLastErrorSource(d, p, x, c, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
13 | #define ConsoleExitWithLastError(x, c, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 13 | #define ConsoleExitWithLastErrorSource(d, x, c, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
14 | 14 | ||
15 | 15 | ||
16 | #define ConsoleExitOnFailure(x, c, f, ...) ConsoleExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
17 | #define ConsoleExitOnLastError(x, c, f, ...) ConsoleExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
18 | #define ConsoleExitOnNull(p, x, e, c, f, ...) ConsoleExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, c, f, __VA_ARGS__) | ||
19 | #define ConsoleExitOnNullWithLastError(p, x, c, f, ...) ConsoleExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, c, f, __VA_ARGS__) | ||
20 | #define ConsoleExitWithLastError(x, c, f, ...) ConsoleExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
21 | |||
16 | // enums | 22 | // enums |
17 | typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; | 23 | typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; |
18 | 24 | ||