diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-05-29 11:22:14 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-06-10 09:42:20 +0200 |
commit | ada4b34ec7159e01af11068f99b28cce8a891ad1 (patch) | |
tree | ac48ef1ae71cbe93c71ade742789170bb53c6112 /src | |
parent | d383acad25f7f57692f88326e5505e9194ffe6dc (diff) | |
download | systemd-ada4b34ec7159e01af11068f99b28cce8a891ad1.tar.gz |
core: rework error messages in unit_add_name()
They were added recently in acd1987a1867fc3390ef2516962b2313cbeb366e. We can
make them more informative by using unit_type_to_string() and not repeating
unit names as much. Also, %m should not be used together with SYNTHETIC_ERRNO().
Diffstat (limited to 'src')
-rw-r--r-- | src/core/unit.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index 4412f6b7b7..091372b9e7 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -275,14 +275,16 @@ int unit_add_name(Unit *u, const char *text) { /* Ensure that this unit either has no instance, or that the instance matches. */ if (u->type != _UNIT_TYPE_INVALID && !streq_ptr(u->instance, instance)) return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EINVAL), - "instance is illegal: u->type(%d), u->instance(%s) and i(%s) for name '%s': %m", - u->type, u->instance, instance, name); + "cannot add name %s, the instances don't match (\"%s\" != \"%s\").", + name, instance, u->instance); if (u->id && !unit_type_may_alias(t)) - return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EEXIST), "aliases are not allowed for name '%s': %m", name); + return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EEXIST), + "cannot add name %s, aliases are not allowed for %s units.", + name, unit_type_to_string(t)); if (hashmap_size(u->manager->units) >= MANAGER_MAX_NAMES) - return log_unit_debug_errno(u, SYNTHETIC_ERRNO(E2BIG), "too many units: %m"); + return log_unit_warning_errno(u, SYNTHETIC_ERRNO(E2BIG), "cannot add name, manager has too many units: %m"); /* Add name to the global hashmap first, because that's easier to undo */ r = hashmap_put(u->manager->units, name, u); |