Fix exceptions referenced in #1287

This commit is contained in:
AlexandreRouma 2024-01-22 19:46:01 +01:00
parent 159f59b858
commit 27ab5bf3c1
13 changed files with 26 additions and 26 deletions

View File

@ -88,7 +88,7 @@ int CommandArgsParser::parse(int argc, char* argv[]) {
try { try {
carg.ival = std::stoi(arg); carg.ival = std::stoi(arg);
} }
catch (std::exception e) { catch (const std::exception& e) {
printf("Invalid argument, failed to parse integer\n"); printf("Invalid argument, failed to parse integer\n");
showHelp(); showHelp();
return -1; return -1;
@ -98,7 +98,7 @@ int CommandArgsParser::parse(int argc, char* argv[]) {
try { try {
carg.fval = std::stod(arg); carg.fval = std::stod(arg);
} }
catch (std::exception e) { catch (const std::exception& e) {
printf("Invalid argument, failed to parse float\n"); printf("Invalid argument, failed to parse float\n");
showHelp(); showHelp();
return -1; return -1;

View File

@ -36,8 +36,8 @@ void ConfigManager::load(json def, bool lock) {
file >> conf; file >> conf;
file.close(); file.close();
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Config file '{0}' is corrupted, resetting it", path); flog::error("Config file '{}' is corrupted, resetting it: {}", path, e.what());
conf = def; conf = def;
save(false); save(false);
} }

View File

@ -320,7 +320,7 @@ namespace net {
} }
entry.handler(std::move(client), entry.ctx); entry.handler(std::move(client), entry.ctx);
} }
catch (std::exception e) { catch (const std::exception& e) {
listening = false; listening = false;
return; return;
} }

View File

@ -80,8 +80,8 @@ public:
try { try {
client = net::rigctl::connect(host, port); client = net::rigctl::connect(host, port);
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Could not connect: {0}", e.what()); flog::error("Could not connect: {}", e.what());
return; return;
} }

View File

@ -200,8 +200,8 @@ private:
listener = net::listen(hostname, port); listener = net::listen(hostname, port);
listener->acceptAsync(clientHandler, this); listener->acceptAsync(clientHandler, this);
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Could not start rigctl server: {0}", e.what()); flog::error("Could not start rigctl server: {}", e.what());
} }
} }

View File

@ -141,10 +141,10 @@ public:
return; return;
} }
} }
catch (std::exception e) { catch (const std::exception& e) {
char buf[1024]; char buf[1024];
sprintf(buf, "%016" PRIX64, serial); sprintf(buf, "%016" PRIX64, serial);
flog::error("Could not open Airspy {0}", buf); flog::error("Could not open Airspy {}", buf);
} }
selectedSerial = serial; selectedSerial = serial;

View File

@ -144,10 +144,10 @@ public:
return; return;
} }
} }
catch (std::exception e) { catch (const std::exception& e) {
char buf[1024]; char buf[1024];
sprintf(buf, "%016" PRIX64, serial); sprintf(buf, "%016" PRIX64, serial);
flog::error("Could not open Airspy HF+ {0}", buf); flog::error("Could not open Airspy HF+ {}", buf);
} }
selectedSerial = serial; selectedSerial = serial;

View File

@ -200,11 +200,11 @@ private:
_this->audio.startStream(); _this->audio.startStream();
_this->running = true; _this->running = true;
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Error opening audio device: {0}", e.what()); flog::error("Error opening audio device: {}", e.what());
} }
flog::info("AudioSourceModule '{0}': Start!", _this->name); flog::info("AudioSourceModule '{}': Start!", _this->name);
} }
static void stop(void* ctx) { static void stop(void* ctx) {

View File

@ -139,8 +139,8 @@ private:
//gui::freqSelect.maxFreq = _this->centerFreq + (_this->sampleRate/2); //gui::freqSelect.maxFreq = _this->centerFreq + (_this->sampleRate/2);
//gui::freqSelect.limitFreq = true; //gui::freqSelect.limitFreq = true;
} }
catch (std::exception& e) { catch (const std::exception& e) {
flog::error("Error: {0}", e.what()); flog::error("Error: {}", e.what());
} }
config.acquire(); config.acquire();
config.conf["path"] = _this->fileSelect.path; config.conf["path"] = _this->fileSelect.path;

View File

@ -154,8 +154,8 @@ private:
_this->client = rfspace::connect(_this->hostname, _this->port, &_this->stream); _this->client = rfspace::connect(_this->hostname, _this->port, &_this->stream);
_this->deviceInit(); _this->deviceInit();
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Could not connect to SDR: {0}", e.what()); flog::error("Could not connect to SDR: {}", e.what());
} }
} }
else if (connected && SmGui::Button("Disconnect##rfspace_source")) { else if (connected && SmGui::Button("Disconnect##rfspace_source")) {

View File

@ -132,8 +132,8 @@ private:
try { try {
_this->client = rtltcp::connect(&_this->stream, _this->ip, _this->port); _this->client = rtltcp::connect(&_this->stream, _this->ip, _this->port);
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Could connect to RTL-TCP server: {0}", e.what()); flog::error("Could connect to RTL-TCP server: {}", e.what());
return; return;
} }

View File

@ -233,8 +233,8 @@ private:
client = server::connect(hostname, port, &stream); client = server::connect(hostname, port, &stream);
deviceInit(); deviceInit();
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Could not connect to SDR: {0}", e.what()); flog::error("Could not connect to SDR: {}", e.what());
if (!strcmp(e.what(), "Server busy")) { serverBusy = true; } if (!strcmp(e.what(), "Server busy")) { serverBusy = true; }
} }
} }

View File

@ -283,8 +283,8 @@ private:
flog::info("Connected to server"); flog::info("Connected to server");
} }
} }
catch (std::exception e) { catch (const std::exception& e) {
flog::error("Could not connect to spyserver {0}", e.what()); flog::error("Could not connect to spyserver {}", e.what());
} }
} }