From 0c999d70dc6ac90cf754e282814733288daebc3b Mon Sep 17 00:00:00 2001 From: Martins Mozeiko Date: Sun, 6 Apr 2025 20:58:35 -0700 Subject: [PATCH] better error message if CreateProcess fails --- src/demon/win32/demon_core_win32.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/demon/win32/demon_core_win32.c b/src/demon/win32/demon_core_win32.c index 5ed5e044..5c40854e 100644 --- a/src/demon/win32/demon_core_win32.c +++ b/src/demon/win32/demon_core_win32.c @@ -1312,7 +1312,13 @@ dmn_ctrl_launch(DMN_CtrlCtx *ctx, OS_ProcessLaunchParams *params) } else { - log_user_errorf("There was an error starting %S.", params->cmd_line.first->string); + DWORD error = GetLastError(); + LPWSTR message = 0; + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, error, MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL), (LPWSTR)&message, 0, 0); + String8 message8 = message ? str8_from_16(scratch.arena, str16_cstring(message)) : str8_lit("unknown error"); + LocalFree(message); + + log_user_errorf("There was an error starting %S: %S", params->cmd_line.first->string, message8); } } scratch_end(scratch);