From: Michael Tremer Date: Wed, 29 Oct 2025 14:44:18 +0000 (+0000) Subject: client: Print any error messages from the daemon X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dfeafb827c6ef01e98ffe1b62c69f1168e78cd39;p=oddments%2Fcollecty.git client: Print any error messages from the daemon Signed-off-by: Michael Tremer --- diff --git a/src/client/main.c b/src/client/main.c index 07776d9..957b098 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -132,6 +132,7 @@ static int render(td_client_ctx* ctx) { sd_bus_message* reply = NULL; const void* buffer = NULL; sd_bus_message* m = NULL; + sd_bus_error error = {}; char path[PATH_MAX]; size_t bytes_written = 0; size_t length = 0; @@ -181,15 +182,38 @@ static int render(td_client_ctx* ctx) { goto ERROR; } + // Send from when we want the graph to be rendered + if (ctx->interval.since) { + r = sd_bus_message_append(m, "{sv}", "since", "s", ctx->interval.since); + if (r < 0) + goto ERROR; + } + + // Send until when we want the graph to be rendered + if (ctx->interval.until) { + r = sd_bus_message_append(m, "{sv}", "until", "s", ctx->interval.until); + if (r < 0) + goto ERROR; + } + // Close the array r = sd_bus_message_close_container(m); if (r < 0) goto ERROR; // Call the message - r = sd_bus_call(ctx->bus, m, 0, NULL, &reply); + r = sd_bus_call(ctx->bus, m, 0, &error, &reply); if (r < 0) { - perror("Failed to call the Render() method"); + // Fetch the error code + errno = sd_bus_error_get_errno(&error); + + // Print the error message + if (error.message) { + fprintf(stderr, "%s: %s\n", program_invocation_name, error.message); + } else { + perror("Failed to call the Render() method"); + } + goto ERROR; }