tree-wide: print error if table_print() fails

We generally want to print an error message if table_print()
fails. Add a helper function for this and use it consistently.
This does one of the three things depending on the call site:
- a no-change reformatting of the code
- change from a custom message to the generic one
- addition of the error message where previously none was printed

In the third case, the actual use impact is very small, since the
table formatting is very unlikely to fail. But if it did, we would
often return an error without any message whatsoever, which we
never want to do.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-03 13:05:03 +02:00
parent 0ce5a8fb4e
commit 1008583c91
39 changed files with 115 additions and 130 deletions
+2 -2
View File
@@ -115,9 +115,9 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n
output_waiting_jobs(bus, table, j->id, "GetJobBefore", "\twaiting for job");
}
r = table_print(table);
r = table_print_or_warn(table);
if (r < 0)
return log_error_errno(r, "Failed to print the table: %m");
return r;
if (arg_legend != 0) {
on = ansi_highlight();