Skip to content

Commit

Permalink
windows/serialInterface: Improved the error diagnostics slightly by p…
Browse files Browse the repository at this point in the history
…reventing the omission of a spurious diagnostic
  • Loading branch information
dragonmux committed Oct 31, 2023
1 parent 998b5b9 commit 596d728
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/windows/serialInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 596d728

Please sign in to comment.