#error "This source should not be compiled without HAVE_NETTLE defined"
#endif
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
{
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) {
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);
#include <os/os.h>
#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
+#include <rfb/util.h>
#include "fltk/layout.h"
#include "ServerDialog.h"
// 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;
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);
/* 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++)
#endif
#include <assert.h>
+#include <errno.h>
#include <stdio.h>
#include <string.h>
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);
#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/SecurityClient.h>
+#include <rfb/util.h>
#include <FL/fl_utf8.h>
/* 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");
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;
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)) {