core: slightly improve error message on load errors

Let's be a bit more helpful when refusing jobs on units that failed to
load properly. We already have explicit D-Bus errors for the error
conditions that are common and expected (such as "not found"), but for
the rest we so far generate a fairly cryptic message.

Let's try to be friendlier towards users and suggest what to do on such
errors.

Fixes: #16487
This commit is contained in:
Lennart Poettering
2021-02-13 17:46:39 +09:00
committed by Yu Watanabe
parent 9ae4f96056
commit 6b10a2e030
+2 -1
View File
@@ -2356,7 +2356,8 @@ int bus_unit_validate_load_state(Unit *u, sd_bus_error *error) {
return sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING, "Unit %s has a bad unit file setting.", u->id);
case UNIT_ERROR: /* Only show .load_error in UNIT_ERROR state */
return sd_bus_error_set_errnof(error, u->load_error, "Unit %s failed to load properly: %m.", u->id);
return sd_bus_error_set_errnof(error, u->load_error,
"Unit %s failed to load properly, please adjust/correct and reload service manager: %m", u->id);
case UNIT_MASKED:
return sd_bus_error_setf(error, BUS_ERROR_UNIT_MASKED, "Unit %s is masked.", u->id);