diff options
author | Thomas Haller <thaller@redhat.com> | 2018-07-10 11:17:05 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-07-20 08:55:14 +0200 |
commit | 4fbed4bedc9f7052d973a658c5ba6890602915c2 (patch) | |
tree | c38b4c859f0d9c897c9b1fb7dca5848f0820de2e | |
parent | 06a360eb36ffc20a6d0567e2b4e54d6fae8bd3e7 (diff) | |
download | NetworkManager-th/not-available-reason.tar.gz |
core: improve error message when activating profileth/not-available-reason
Before:
$ nmcli connection up my-wired
Error: Connection activation failed: No suitable device found for this connection.
After:
$ nmcli connection up my-wired
Error: Connection activation failed: No suitable device found for this connection (device eth0 not available because device has no carrier).
This relies on nm_manager_get_best_device_for_connection() giving a
suitable error. That is however a bit complicated, because if no
suitable device is found, it's not immediately clear what is the
exact reason. E.g. if you try to activate a Wi-Fi profile, the
failure reason
"SSID is not visible"
is better than
"Wi-Fi profile cannot activate on ethernet device".
This is controlled by carefully setting the failure codes
NM_UTILS_ERROR_CONNECTION_AVAILABLE_* to indicate an absolute
relevance of the failure. And subsequently, by selecting the failure
with the highest relevance. This might still need some improvements,
for example by reordering checks (so that more relevant failures
are handled first) and tweaking the error relevance.
-rw-r--r-- | src/nm-manager.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c index 4bb2e674c5..630180963a 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4634,17 +4634,20 @@ validate_activation_request (NMManager *self, return NULL; } } else if (!is_vpn) { - device = nm_manager_get_best_device_for_connection (self, connection, TRUE, NULL, NULL); + gs_free_error GError *local = NULL; + + device = nm_manager_get_best_device_for_connection (self, connection, TRUE, NULL, &local); if (!device) { gs_free char *iface = NULL; /* VPN and software-device connections don't need a device yet, * but non-virtual connections do ... */ if (!nm_connection_is_virtual (connection)) { - g_set_error_literal (error, - NM_MANAGER_ERROR, - NM_MANAGER_ERROR_UNKNOWN_DEVICE, - "No suitable device found for this connection."); + g_set_error (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_UNKNOWN_DEVICE, + "No suitable device found for this connection (%s).", + local->message); return NULL; } |