From 211aa9a5d7b552842594922d36c2ad24180fcba9 Mon Sep 17 00:00:00 2001 From: Ola Olsson Date: Wed, 19 Dec 2018 16:18:36 +0100 Subject: [PATCH] Add failure description (from errno) when failing to open device Maybe I should throw an FileOpenError instead? --- src/BossaWindow.cpp | 4 +++- src/PosixSerialPort.cpp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BossaWindow.cpp b/src/BossaWindow.cpp index eb046e8e..14584a80 100644 --- a/src/BossaWindow.cpp +++ b/src/BossaWindow.cpp @@ -280,10 +280,12 @@ BossaWindow::OnSerial(wxCommandEvent& event) Samba& samba = wxGetApp().samba; wxString port = _portComboBox->GetString(event.GetSelection()); + errno = 0; + if (!samba.connect(portFactory.create(std::string(port.mb_str())))) { Disconnected(); - Error(wxString::Format(_("Could not connect to device on %s"), port.c_str())); + Error(wxString::Format(_("Could not connect to device on %s: %s"), port.c_str(), strerror(errno))); return; } diff --git a/src/PosixSerialPort.cpp b/src/PosixSerialPort.cpp index 45eaca9c..90e8f9a9 100644 --- a/src/PosixSerialPort.cpp +++ b/src/PosixSerialPort.cpp @@ -32,9 +32,7 @@ #include #include #include -#include #include -#include #include #include