diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-11-07 10:37:53 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-11-07 10:37:53 +0100 |
commit | f7507aea98b1a428d02fe5c41d25ee69dd5436bb (patch) | |
tree | 49f9349a1d7441874d1cb6d4428e2bcb0d63b422 /vncviewer/ServerDialog.cxx | |
parent | 7508e9887de022e127d8fadb9f6a6bd8e9778864 (diff) | |
parent | 2b7857283b834391266e414adcff8c20f8fe3067 (diff) | |
download | tigervnc-f7507aea98b1a428d02fe5c41d25ee69dd5436bb.tar.gz tigervnc-f7507aea98b1a428d02fe5c41d25ee69dd5436bb.zip |
Merge branch 'stdexcept' of github.com:CendioOssman/tigervnc
Diffstat (limited to 'vncviewer/ServerDialog.cxx')
-rw-r--r-- | vncviewer/ServerDialog.cxx | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index 8622fff1..e24438d6 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -36,7 +36,9 @@ #include <FL/Fl_File_Chooser.H> #include <os/os.h> -#include <rfb/Exception.h> + +#include <rdr/Exception.h> + #include <rfb/Hostname.h> #include <rfb/LogWriter.h> #include <rfb/util.h> @@ -140,10 +142,10 @@ void ServerDialog::run(const char* servername, char *newservername) for (const string& entry : dialog.serverHistory) fltk_menu_add(dialog.serverName->menubutton(), entry.c_str(), 0, nullptr); - } catch (Exception& e) { - vlog.error("%s", e.str()); + } catch (std::exception& e) { + vlog.error("%s", e.what()); fl_alert(_("Unable to load the server history:\n\n%s"), - e.str()); + e.what()); } while (dialog.shown()) Fl::wait(); @@ -192,10 +194,10 @@ void ServerDialog::handleLoad(Fl_Widget* /*widget*/, void* data) try { dialog->serverName->value(loadViewerParameters(filename)); - } catch (Exception& e) { - vlog.error("%s", e.str()); + } catch (std::exception& e) { + vlog.error("%s", e.what()); fl_alert(_("Unable to load the specified configuration file:\n\n%s"), - e.str()); + e.what()); } delete(file_chooser); @@ -253,10 +255,10 @@ void ServerDialog::handleSaveAs(Fl_Widget* /*widget*/, void* data) try { saveViewerParameters(filename, servername); - } catch (Exception& e) { - vlog.error("%s", e.str()); + } catch (std::exception& e) { + vlog.error("%s", e.what()); fl_alert(_("Unable to save the specified configuration " - "file:\n\n%s"), e.str()); + "file:\n\n%s"), e.what()); } delete(file_chooser); @@ -287,10 +289,10 @@ void ServerDialog::handleConnect(Fl_Widget* /*widget*/, void *data) try { saveViewerParameters(nullptr, servername); - } catch (Exception& e) { - vlog.error("%s", e.str()); + } catch (std::exception& e) { + vlog.error("%s", e.what()); fl_alert(_("Unable to save the default configuration:\n\n%s"), - e.str()); + e.what()); } // avoid duplicates in the history @@ -299,10 +301,10 @@ void ServerDialog::handleConnect(Fl_Widget* /*widget*/, void *data) try { dialog->saveServerHistory(); - } catch (Exception& e) { - vlog.error("%s", e.str()); + } catch (std::exception& e) { + vlog.error("%s", e.what()); fl_alert(_("Unable to save the server history:\n\n%s"), - e.str()); + e.what()); } } @@ -320,7 +322,7 @@ static bool same_server(const string& a, const string& b) try { getHostAndPort(a.c_str(), &hostA, &portA); getHostAndPort(b.c_str(), &hostB, &portB); - } catch (Exception& e) { + } catch (std::exception& e) { return false; } @@ -346,7 +348,7 @@ void ServerDialog::loadServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not determine VNC state directory path")); + throw std::runtime_error(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); @@ -359,7 +361,7 @@ void ServerDialog::loadServerHistory() return; } std::string msg = format(_("Could not open \"%s\""), filepath); - throw rdr::PosixException(msg.c_str(), errno); + throw rdr::posix_error(msg.c_str(), errno); } int lineNr = 0; @@ -375,15 +377,18 @@ void ServerDialog::loadServerHistory() fclose(f); std::string msg = format(_("Failed to read line %d in " "file \"%s\""), lineNr, filepath); - throw rdr::PosixException(msg.c_str(), errno); + throw rdr::posix_error(msg.c_str(), errno); } int len = strlen(line); if (len == (sizeof(line) - 1)) { fclose(f); - throw Exception(_("Failed to read line %d in file %s: %s"), - lineNr, filepath, _("Line too long")); + throw std::runtime_error(format("%s: %s", + format(_("Failed to read line %d " + "in file %s"), + lineNr, filepath).c_str(), + _("Line too long"))); } if ((len > 0) && (line[len-1] == '\n')) { @@ -422,7 +427,7 @@ void ServerDialog::saveServerHistory() const char* stateDir = os::getvncstatedir(); if (stateDir == nullptr) - throw Exception(_("Could not determine VNC state directory path")); + throw std::runtime_error(_("Could not determine VNC state directory path")); char filepath[PATH_MAX]; snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY); @@ -431,7 +436,7 @@ void ServerDialog::saveServerHistory() FILE* f = fopen(filepath, "w+"); if (!f) { std::string msg = format(_("Could not open \"%s\""), filepath); - throw rdr::PosixException(msg.c_str(), errno); + throw rdr::posix_error(msg.c_str(), errno); } // Save the last X elements to the config file. |