From bc8c1471ab7083ebb60b8c3b049ce990bbd215b7 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 4 Jun 2021 11:02:17 +0200 Subject: [PATCH] - catch exception if requesting service name fails --- client/snapper.cc | 2 +- server/snapperd.cc | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/client/snapper.cc b/client/snapper.cc index 8ec382560..76021f225 100644 --- a/client/snapper.cc +++ b/client/snapper.cc @@ -129,7 +129,7 @@ main(int argc, char** argv) } catch (const runtime_error& e) { - cerr << _("Failed to set locale. Fix your system.") << endl; + cerr << _("Failed to set locale.") << endl; } setLogDo(&log_do); diff --git a/server/snapperd.cc b/server/snapperd.cc index cd19230e9..afc3433c7 100644 --- a/server/snapperd.cc +++ b/server/snapperd.cc @@ -275,7 +275,18 @@ main(int argc, char** argv) y2mil("Requesting DBus name"); - mainloop.request_name(SERVICE, DBUS_NAME_FLAG_REPLACE_EXISTING); + try + { + mainloop.request_name(SERVICE, DBUS_NAME_FLAG_REPLACE_EXISTING); + } + catch (const Exception& e) + { + SN_CAUGHT(e); + + y2err("Failed to request DBus name"); + + return EXIT_FAILURE; + } y2mil("Loading snapper configs"); @@ -287,7 +298,7 @@ main(int argc, char** argv) { SN_CAUGHT(e); - y2err("failed to load snapper configs"); + y2err("Failed to load snapper configs"); } y2mil("Listening for method calls and signals"); @@ -298,5 +309,5 @@ main(int argc, char** argv) meta_snappers.unload(); - return 0; + return EXIT_SUCCESS; }