From 596d7286d2b5adc855cc00f12fd1e70f2c85e409 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Tue, 31 Oct 2023 20:15:16 +0000 Subject: [PATCH] windows/serialInterface: Improved the error diagnostics slightly by preventing the omission of a spurious diagnostic --- src/windows/serialInterface.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/windows/serialInterface.cxx b/src/windows/serialInterface.cxx index 3bc36df..c9def6f 100644 --- a/src/windows/serialInterface.cxx +++ b/src/windows/serialInterface.cxx @@ -218,6 +218,9 @@ void serialInterface_t::handleDeviceError(const std::string_view operation) noex { // Get the last error that occured const auto error{GetLastError()}; + // If there is no error and no device (we failed to look up the device node), return early + if (error == ERROR_SUCCESS && device == INVALID_HANDLE_VALUE) + return; char *message{nullptr}; // Ask Windows to please tell us what the error value we have means, and allocate + store it in `message` FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,