diff options
-rw-r--r-- | common/rfb/SSecurityRSAAES.cxx | 5 | ||||
-rw-r--r-- | vncviewer/ServerDialog.cxx | 17 | ||||
-rw-r--r-- | vncviewer/UserDialog.cxx | 3 | ||||
-rw-r--r-- | vncviewer/parameters.cxx | 17 |
4 files changed, 25 insertions, 17 deletions
diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx index 5b3a04d2..92b332d6 100644 --- a/common/rfb/SSecurityRSAAES.cxx +++ b/common/rfb/SSecurityRSAAES.cxx @@ -24,6 +24,7 @@ #error "This source should not be compiled without HAVE_NETTLE defined" #endif +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -155,7 +156,7 @@ void SSecurityRSAAES::loadPrivateKey() { FILE* file = fopen(keyFile, "rb"); if (!file) - throw Exception("failed to open key file"); + throw rdr::SystemException("failed to open key file", errno); fseek(file, 0, SEEK_END); size_t size = ftell(file); if (size == 0 || size > MaxKeyFileSize) { @@ -166,7 +167,7 @@ void SSecurityRSAAES::loadPrivateKey() std::vector<uint8_t> data(size); if (fread(data.data(), 1, data.size(), file) != size) { fclose(file); - throw Exception("failed to read key"); + throw rdr::SystemException("failed to read key", errno); } fclose(file); diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index d51b8713..f9e3ffb3 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -38,6 +38,7 @@ #include <os/os.h> #include <rfb/Exception.h> #include <rfb/LogWriter.h> +#include <rfb/util.h> #include "fltk/layout.h" #include "ServerDialog.h" @@ -329,8 +330,8 @@ void ServerDialog::loadServerHistory() // no history file return; } - throw Exception(_("Could not open \"%s\": %s"), - filepath, strerror(errno)); + std::string msg = format(_("Could not open \"%s\""), filepath); + throw rdr::SystemException(msg.c_str(), errno); } int lineNr = 0; @@ -344,8 +345,9 @@ void ServerDialog::loadServerHistory() break; fclose(f); - throw Exception(_("Failed to read line %d in file %s: %s"), - lineNr, filepath, strerror(errno)); + std::string msg = format(_("Failed to read line %d in " + "file \"%s\""), lineNr, filepath); + throw rdr::SystemException(msg.c_str(), errno); } int len = strlen(line); @@ -390,9 +392,10 @@ void ServerDialog::saveServerHistory() /* Write server history to file */ FILE* f = fopen(filepath, "w+"); - if (!f) - throw Exception(_("Could not open \"%s\": %s"), - filepath, strerror(errno)); + if (!f) { + std::string msg = format(_("Could not open \"%s\""), filepath); + throw rdr::SystemException(msg.c_str(), errno); + } // Save the last X elements to the config file. for(size_t idx=0; idx < serverHistory.size() && idx <= SERVER_HISTORY_SIZE; idx++) diff --git a/vncviewer/UserDialog.cxx b/vncviewer/UserDialog.cxx index 13821a9c..6ea67d6d 100644 --- a/vncviewer/UserDialog.cxx +++ b/vncviewer/UserDialog.cxx @@ -21,6 +21,7 @@ #endif #include <assert.h> +#include <errno.h> #include <stdio.h> #include <string.h> @@ -114,7 +115,7 @@ void UserDialog::getUserPasswd(bool secure_, std::string* user, fp = fopen(passwordFileName, "rb"); if (!fp) - throw rfb::Exception(_("Opening password file failed")); + throw rdr::SystemException(_("Opening password file failed"), errno); obfPwd.resize(fread(obfPwd.data(), 1, obfPwd.size(), fp)); fclose(fp); diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 2e8ad7a1..e40391a2 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -36,6 +36,7 @@ #include <rfb/Exception.h> #include <rfb/LogWriter.h> #include <rfb/SecurityClient.h> +#include <rfb/util.h> #include <FL/fl_utf8.h> @@ -640,9 +641,10 @@ void saveViewerParameters(const char *filename, const char *servername) { /* Write parameters to file */ FILE* f = fopen(filepath, "w+"); - if (!f) - throw Exception(_("Could not open \"%s\": %s"), - filepath, strerror(errno)); + if (!f) { + std::string msg = format(_("Could not open \"%s\""), filepath); + throw rdr::SystemException(msg.c_str(), errno); + } fprintf(f, "%s\n", IDENTIFIER_STRING); fprintf(f, "\n"); @@ -747,8 +749,8 @@ char* loadViewerParameters(const char *filename) { if (!f) { if (!filename) return nullptr; // Use defaults. - throw Exception(_("Could not open \"%s\": %s"), - filepath, strerror(errno)); + std::string msg = format(_("Could not open \"%s\""), filepath); + throw rdr::SystemException(msg.c_str(), errno); } int lineNr = 0; @@ -761,8 +763,9 @@ char* loadViewerParameters(const char *filename) { break; fclose(f); - throw Exception(_("Failed to read line %d in file %s: %s"), - lineNr, filepath, strerror(errno)); + std::string msg = format(_("Failed to read line %d in " + "file \"%s\""), lineNr, filepath); + throw rdr::SystemException(msg.c_str(), errno); } if (strlen(line) == (sizeof(line) - 1)) { |