mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
print GetLastError() result instead of errno
This commit is contained in:
parent
827c4a784d
commit
53caef260d
@ -74,15 +74,15 @@ Serial::SerialImpl::open ()
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
if (fd_ == INVALID_HANDLE_VALUE) {
|
if (fd_ == INVALID_HANDLE_VALUE) {
|
||||||
DWORD errno_ = GetLastError();
|
DWORD create_file_err = GetLastError();
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
switch (errno_) {
|
switch (create_file_err) {
|
||||||
case ERROR_FILE_NOT_FOUND:
|
case ERROR_FILE_NOT_FOUND:
|
||||||
// Use this->getPort to convert to a std::string
|
// Use this->getPort to convert to a std::string
|
||||||
ss << "Specified port, " << this->getPort() << ", does not exist.";
|
ss << "Specified port, " << this->getPort() << ", does not exist.";
|
||||||
THROW (IOException, ss.str().c_str());
|
THROW (IOException, ss.str().c_str());
|
||||||
default:
|
default:
|
||||||
ss << "Unknown error opening the serial port: " << errno;
|
ss << "Unknown error opening the serial port: " << create_file_err;
|
||||||
THROW (IOException, ss.str().c_str());
|
THROW (IOException, ss.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user