From f35eccb3a7bded50dc43bab01c75a478d6cb6688 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Sun, 22 Sep 2024 20:49:15 -0700 Subject: [PATCH] error enum in FormatMessage --- win32/src/winapi/error.rs | 1 + win32/src/winapi/kernel32/misc.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/win32/src/winapi/error.rs b/win32/src/winapi/error.rs index def5fbb28..bc53e49d3 100644 --- a/win32/src/winapi/error.rs +++ b/win32/src/winapi/error.rs @@ -10,6 +10,7 @@ pub enum ERROR { INVALID_HANDLE = 6, INVALID_ACCESS = 12, INVALID_DATA = 13, + OUT_OF_PAPER = 28, FILE_EXISTS = 80, OPEN_FAILED = 110, MOD_NOT_FOUND = 126, diff --git a/win32/src/winapi/kernel32/misc.rs b/win32/src/winapi/kernel32/misc.rs index dd236b9e8..22c36eb18 100644 --- a/win32/src/winapi/kernel32/misc.rs +++ b/win32/src/winapi/kernel32/misc.rs @@ -261,9 +261,10 @@ pub fn FormatMessageW( todo!(); } let msg = if flags.contains(FormatMessageFlags::FROM_SYSTEM) { - match dwMessageId { - 0x1c => "The printer is out of paper.", - id => todo!("system message {:x}", id), + match ERROR::try_from(dwMessageId) { + Ok(ERROR::FILE_NOT_FOUND) => "The system cannot find the file specified.", + Ok(ERROR::OUT_OF_PAPER) => "The printer is out of paper.", + err => todo!("system error {err:x?}"), } } else { todo!();