summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-07-10 11:17:05 +0200
committerThomas Haller <thaller@redhat.com>2018-07-24 09:39:09 +0200
commit3000ade72af4373f3a53e2b6d02d54fc3ce33513 (patch)
tree27c6e37d2762fb1613a8d461bb89e4f93f431101
parente9f6bb0bbb5404a1bc4ecdb3b1812970fa2c98c4 (diff)
downloadNetworkManager-3000ade72af4373f3a53e2b6d02d54fc3ce33513.tar.gz
core: improve error message when activating profile
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.c13
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;
}