From 855bd143d92d41e3bea4194f270bb92b417c02f7 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Wed, 5 Jan 2022 16:10:23 +0100 Subject: [PATCH] libdbus-p2p: better error reporting Change-Id: Ie172dcf45da6a2eb82f37cbb9a9eca7a31ebb4bf Signed-off-by: Michal Bloch --- benchmark/libdbus-p2p-server.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/benchmark/libdbus-p2p-server.cpp b/benchmark/libdbus-p2p-server.cpp index 0a80407..0540dfd 100644 --- a/benchmark/libdbus-p2p-server.cpp +++ b/benchmark/libdbus-p2p-server.cpp @@ -338,12 +338,22 @@ int main (int argc, char ** argv) return EXIT_FAILURE; } + DBusError derror; + dbus_error_init (& derror); + /* thread_local ensures the destructor runs, the destructor doesn't * run on std::exit without it as per the std::exit specification. * Otherwise it makes no difference since we're single-threaded. */ - thread_local std::unique_ptr server (dbus_server_listen (("unix:path=" + opt.sock_path).c_str(), nullptr)); + thread_local std::unique_ptr server (dbus_server_listen (("unix:path=" + opt.sock_path).c_str(), & derror)); if (!server) { - std::cerr << "listening on " << opt.sock_path << "failed" << std::endl; + + if (dbus_error_is_set (&derror)) { + std::cerr << derror.name << ": " << derror.message << std::endl; + dbus_error_free (&derror); // stack var is fine, doesn't actually free the memory + } else { + std::cerr << "listening on " << opt.sock_path << " failed (unknown error)" << std::endl; + } + return EXIT_FAILURE; } -- 2.34.1