return 0;
}
+static void notify_bus_error(const sd_bus_error *error) {
+
+ if (!sd_bus_error_is_set(error))
+ return;
+
+ (void) sd_notifyf(/* unset_environment= */ false, "BUSERROR=%s", error->name);
+}
+
static int list_bus_names(int argc, char **argv, void *userdata) {
_cleanup_strv_free_ char **acquired = NULL, **activatable = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
"org.freedesktop.DBus.Introspectable", "Introspect",
&error, &reply, NULL);
if (r < 0) {
+ notify_bus_error(&error);
printf("%sFailed to introspect object %s of service %s: %s%s\n",
ansi_highlight_red(),
path, service, bus_error_message(&error, r),
r = sd_bus_call_method(bus, argv[1], argv[2],
"org.freedesktop.DBus.Introspectable", "Introspect",
&error, &reply_xml, NULL);
- if (r < 0)
+ if (r < 0) {
+ notify_bus_error(&error);
return log_error_errno(r, "Failed to introspect object %s of service %s: %s",
argv[2], argv[1], bus_error_message(&error, r));
+ }
r = sd_bus_message_read(reply_xml, "s", &xml);
if (r < 0)
r = sd_bus_call_method(bus, argv[1], argv[2],
"org.freedesktop.DBus.Properties", "GetAll",
&error, &reply, "s", m->interface);
- if (r < 0)
+ if (r < 0) {
+ notify_bus_error(&error);
return log_error_errno(r, "Failed to get all properties on interface %s: %s",
m->interface, bus_error_message(&error, r));
+ }
r = sd_bus_message_enter_container(reply, 'a', "{sv}");
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_call(bus, message, arg_timeout, &error, NULL);
- if (r < 0)
+ if (r < 0) {
+ notify_bus_error(&error);
return log_error_errno(r, "Call to org.freedesktop.DBus.Monitoring.BecomeMonitor failed: %s",
bus_error_message(&error, r));
+ }
r = sd_bus_get_unique_name(bus, &unique_name);
if (r < 0)
}
r = sd_bus_call(bus, m, arg_timeout, &error, &reply);
- if (r < 0)
+ if (r < 0) {
+ notify_bus_error(&error);
return log_error_errno(r, "Call failed: %s", bus_error_message(&error, r));
+ }
r = sd_bus_message_is_empty(reply);
if (r < 0)
r = sd_bus_call_method(bus, argv[1], argv[2],
"org.freedesktop.DBus.Properties", "Get",
&error, &reply, "ss", argv[3], *i);
- if (r < 0)
+ if (r < 0) {
+ notify_bus_error(&error);
return log_error_errno(r, "Failed to get property %s on interface %s: %s",
*i, argv[3],
bus_error_message(&error, r));
+ }
r = sd_bus_message_peek_type(reply, &type, &contents);
if (r < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Too many parameters for signature.");
r = sd_bus_call(bus, m, arg_timeout, &error, NULL);
- if (r < 0)
+ if (r < 0) {
+ notify_bus_error(&error);
return log_error_errno(r, "Failed to set property %s on interface %s: %s",
argv[4], argv[3],
bus_error_message(&error, r));
+ }
return 0;
}