From 27ab5bf3c194169ddf60ca312723fce96149cc8e Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Mon, 22 Jan 2024 19:46:01 +0100 Subject: [PATCH] Fix exceptions referenced in #1287 --- core/src/command_args.cpp | 4 ++-- core/src/config.cpp | 4 ++-- core/src/utils/networking.cpp | 2 +- misc_modules/rigctl_client/src/main.cpp | 4 ++-- misc_modules/rigctl_server/src/main.cpp | 4 ++-- source_modules/airspy_source/src/main.cpp | 4 ++-- source_modules/airspyhf_source/src/main.cpp | 4 ++-- source_modules/audio_source/src/main.cpp | 6 +++--- source_modules/file_source/src/main.cpp | 4 ++-- source_modules/rfspace_source/src/main.cpp | 4 ++-- source_modules/rtl_tcp_source/src/main.cpp | 4 ++-- source_modules/sdrpp_server_source/src/main.cpp | 4 ++-- source_modules/spyserver_source/src/main.cpp | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/core/src/command_args.cpp b/core/src/command_args.cpp index a25120fa..9b3174ce 100644 --- a/core/src/command_args.cpp +++ b/core/src/command_args.cpp @@ -88,7 +88,7 @@ int CommandArgsParser::parse(int argc, char* argv[]) { try { carg.ival = std::stoi(arg); } - catch (std::exception e) { + catch (const std::exception& e) { printf("Invalid argument, failed to parse integer\n"); showHelp(); return -1; @@ -98,7 +98,7 @@ int CommandArgsParser::parse(int argc, char* argv[]) { try { carg.fval = std::stod(arg); } - catch (std::exception e) { + catch (const std::exception& e) { printf("Invalid argument, failed to parse float\n"); showHelp(); return -1; diff --git a/core/src/config.cpp b/core/src/config.cpp index dbfdbe64..6de1888f 100644 --- a/core/src/config.cpp +++ b/core/src/config.cpp @@ -36,8 +36,8 @@ void ConfigManager::load(json def, bool lock) { file >> conf; file.close(); } - catch (std::exception e) { - flog::error("Config file '{0}' is corrupted, resetting it", path); + catch (const std::exception& e) { + flog::error("Config file '{}' is corrupted, resetting it: {}", path, e.what()); conf = def; save(false); } diff --git a/core/src/utils/networking.cpp b/core/src/utils/networking.cpp index a5e727d5..8e89c809 100644 --- a/core/src/utils/networking.cpp +++ b/core/src/utils/networking.cpp @@ -320,7 +320,7 @@ namespace net { } entry.handler(std::move(client), entry.ctx); } - catch (std::exception e) { + catch (const std::exception& e) { listening = false; return; } diff --git a/misc_modules/rigctl_client/src/main.cpp b/misc_modules/rigctl_client/src/main.cpp index 3df6c077..83350ba5 100644 --- a/misc_modules/rigctl_client/src/main.cpp +++ b/misc_modules/rigctl_client/src/main.cpp @@ -80,8 +80,8 @@ public: try { client = net::rigctl::connect(host, port); } - catch (std::exception e) { - flog::error("Could not connect: {0}", e.what()); + catch (const std::exception& e) { + flog::error("Could not connect: {}", e.what()); return; } diff --git a/misc_modules/rigctl_server/src/main.cpp b/misc_modules/rigctl_server/src/main.cpp index d0e4db8a..3673d4dd 100644 --- a/misc_modules/rigctl_server/src/main.cpp +++ b/misc_modules/rigctl_server/src/main.cpp @@ -200,8 +200,8 @@ private: listener = net::listen(hostname, port); listener->acceptAsync(clientHandler, this); } - catch (std::exception e) { - flog::error("Could not start rigctl server: {0}", e.what()); + catch (const std::exception& e) { + flog::error("Could not start rigctl server: {}", e.what()); } } diff --git a/source_modules/airspy_source/src/main.cpp b/source_modules/airspy_source/src/main.cpp index 5457e1dd..28474820 100644 --- a/source_modules/airspy_source/src/main.cpp +++ b/source_modules/airspy_source/src/main.cpp @@ -141,10 +141,10 @@ public: return; } } - catch (std::exception e) { + catch (const std::exception& e) { char buf[1024]; sprintf(buf, "%016" PRIX64, serial); - flog::error("Could not open Airspy {0}", buf); + flog::error("Could not open Airspy {}", buf); } selectedSerial = serial; diff --git a/source_modules/airspyhf_source/src/main.cpp b/source_modules/airspyhf_source/src/main.cpp index 066866a2..cd03b3fe 100644 --- a/source_modules/airspyhf_source/src/main.cpp +++ b/source_modules/airspyhf_source/src/main.cpp @@ -144,10 +144,10 @@ public: return; } } - catch (std::exception e) { + catch (const std::exception& e) { char buf[1024]; sprintf(buf, "%016" PRIX64, serial); - flog::error("Could not open Airspy HF+ {0}", buf); + flog::error("Could not open Airspy HF+ {}", buf); } selectedSerial = serial; diff --git a/source_modules/audio_source/src/main.cpp b/source_modules/audio_source/src/main.cpp index e573a818..df4701e8 100644 --- a/source_modules/audio_source/src/main.cpp +++ b/source_modules/audio_source/src/main.cpp @@ -200,11 +200,11 @@ private: _this->audio.startStream(); _this->running = true; } - catch (std::exception e) { - flog::error("Error opening audio device: {0}", e.what()); + catch (const std::exception& e) { + 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) { diff --git a/source_modules/file_source/src/main.cpp b/source_modules/file_source/src/main.cpp index 0628a412..2b51639a 100644 --- a/source_modules/file_source/src/main.cpp +++ b/source_modules/file_source/src/main.cpp @@ -139,8 +139,8 @@ private: //gui::freqSelect.maxFreq = _this->centerFreq + (_this->sampleRate/2); //gui::freqSelect.limitFreq = true; } - catch (std::exception& e) { - flog::error("Error: {0}", e.what()); + catch (const std::exception& e) { + flog::error("Error: {}", e.what()); } config.acquire(); config.conf["path"] = _this->fileSelect.path; diff --git a/source_modules/rfspace_source/src/main.cpp b/source_modules/rfspace_source/src/main.cpp index d28f1ddb..e0078efb 100644 --- a/source_modules/rfspace_source/src/main.cpp +++ b/source_modules/rfspace_source/src/main.cpp @@ -154,8 +154,8 @@ private: _this->client = rfspace::connect(_this->hostname, _this->port, &_this->stream); _this->deviceInit(); } - catch (std::exception e) { - flog::error("Could not connect to SDR: {0}", e.what()); + catch (const std::exception& e) { + flog::error("Could not connect to SDR: {}", e.what()); } } else if (connected && SmGui::Button("Disconnect##rfspace_source")) { diff --git a/source_modules/rtl_tcp_source/src/main.cpp b/source_modules/rtl_tcp_source/src/main.cpp index 7fe58b94..a1afea57 100644 --- a/source_modules/rtl_tcp_source/src/main.cpp +++ b/source_modules/rtl_tcp_source/src/main.cpp @@ -132,8 +132,8 @@ private: try { _this->client = rtltcp::connect(&_this->stream, _this->ip, _this->port); } - catch (std::exception e) { - flog::error("Could connect to RTL-TCP server: {0}", e.what()); + catch (const std::exception& e) { + flog::error("Could connect to RTL-TCP server: {}", e.what()); return; } diff --git a/source_modules/sdrpp_server_source/src/main.cpp b/source_modules/sdrpp_server_source/src/main.cpp index af4cfcc6..38c187de 100644 --- a/source_modules/sdrpp_server_source/src/main.cpp +++ b/source_modules/sdrpp_server_source/src/main.cpp @@ -233,8 +233,8 @@ private: client = server::connect(hostname, port, &stream); deviceInit(); } - catch (std::exception e) { - flog::error("Could not connect to SDR: {0}", e.what()); + catch (const std::exception& e) { + flog::error("Could not connect to SDR: {}", e.what()); if (!strcmp(e.what(), "Server busy")) { serverBusy = true; } } } diff --git a/source_modules/spyserver_source/src/main.cpp b/source_modules/spyserver_source/src/main.cpp index 59b2214f..d4f87559 100644 --- a/source_modules/spyserver_source/src/main.cpp +++ b/source_modules/spyserver_source/src/main.cpp @@ -283,8 +283,8 @@ private: flog::info("Connected to server"); } } - catch (std::exception e) { - flog::error("Could not connect to spyserver {0}", e.what()); + catch (const std::exception& e) { + flog::error("Could not connect to spyserver {}", e.what()); } }