chiark / gitweb /
core/transaction: avoid misleading error message when unit not found
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jun 2014 18:04:23 +0000 (14:04 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jun 2014 19:30:24 +0000 (15:30 -0400)
There's no point in telling the user to look at the logs when
an attempt to load the unit file failed with ENOENT.

https://bugzilla.redhat.com/show_bug.cgi?id=996133

TODO
src/core/transaction.c

diff --git a/TODO b/TODO
index ff065bf2013e5bb7c55d5c5e69e1e31d5fda0db8..09d8bd38a44de3ef29af0b103cc2d2ba78fcefbb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -15,10 +15,6 @@ Bugfixes:
 
 * properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
 
-* shorten the message to sane length:
-  "Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service
-  failed to load: No such file or directory. See system logs and 'systemctl status display-manager.service' for details."
-
 * sd_bus_unref() is broken regarding self-references and "pseudo thread-safety".
   See the comment in sd_bus_unref() for more..
 
index 9fb6101ea96de69bd841cfb6542987f93d15577c..d23a45c3f517b776351ec7c75bdc37ecd4dfaa4b 100644 (file)
@@ -870,12 +870,18 @@ int transaction_add_job_and_dependencies(
         }
 
         if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
-                sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
-                                  "Unit %s failed to load: %s. "
-                                  "See system logs and 'systemctl status %s' for details.",
-                                  unit->id,
-                                  strerror(-unit->load_error),
-                                  unit->id);
+                if (unit->load_error == -ENOENT)
+                        sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
+                                          "Unit %s failed to load: %s.",
+                                          unit->id,
+                                          strerror(-unit->load_error));
+                else
+                        sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
+                                          "Unit %s failed to load: %s. "
+                                          "See system logs and 'systemctl status %s' for details.",
+                                          unit->id,
+                                          strerror(-unit->load_error),
+                                          unit->id);
                 return -EINVAL;
         }