From 8270567bc62db8f94a6e142b3b170a3bb943c090 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 10 Apr 2015 15:31:15 +0200 Subject: Avoid having exceptions triggering abort() --- src/DabMod.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/DabMod.cpp') diff --git a/src/DabMod.cpp b/src/DabMod.cpp index b713d30..ec1a4cd 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -110,7 +110,7 @@ enum run_modulator_state { run_modulator_state run_modulator(Logger& logger, modulator_data& m); -int main(int argc, char* argv[]) +int launch_modulator(int argc, char* argv[]) { int ret = 0; bool loop = false; @@ -899,3 +899,19 @@ run_modulator_state run_modulator(Logger& logger, modulator_data& m) return ret; } +int main(int argc, char* argv[]) +{ + try { + return launch_modulator(argc, argv); + } + catch (std::invalid_argument& e) { + std::string what(e.what()); + if (not what.empty()) { + std::cerr << "Modulator error: " << what << std::endl; + } + } + catch (std::runtime_error& e) { + std::cerr << "Modulator runtime error: " << e.what() << std::endl; + } +} + -- cgit v1.2.3