From 95658d532e034f387a955a05e8652d2ac136ff58 Mon Sep 17 00:00:00 2001 From: Marcos Slomp Date: Tue, 2 Dec 2025 10:56:38 -0800 Subject: [PATCH] isolating error actions --- public/client/windows/TracyETW.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/public/client/windows/TracyETW.cpp b/public/client/windows/TracyETW.cpp index 73762524..6869559c 100644 --- a/public/client/windows/TracyETW.cpp +++ b/public/client/windows/TracyETW.cpp @@ -20,6 +20,18 @@ struct Session { CONTROLTRACE_ID handle = 0; }; +static void ETWErrorAction(ULONG error_code, const char* message, int length) { +#ifdef TRACY_HAS_CALLSTACK + tracy::InitCallstackCritical(); + TracyMessageCS(message, length, tracy::Color::Red4, 60); +#else + TracyMessageC(message, length, tracy::Color::Red4); +#endif +#ifdef __cpp_exceptions + // TODO: should we throw an exception? +#endif +} + static ULONG ETWError(ULONG result) { if (result == ERROR_SUCCESS) return result; @@ -35,11 +47,7 @@ static ULONG ETWError(ULONG result) { sizeof(message)-written, NULL ); - tracy::InitCallstackCritical(); - TracyMessageCS(message, written, tracy::Color::Red4, 60); -#ifdef __cpp_exceptions - // TODO: should we throw an exception? -#endif + ETWErrorAction(result, message, written); return result; }