From e9f6bb0bbb5404a1bc4ecdb3b1812970fa2c98c4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 10 Jul 2018 11:17:05 +0200 Subject: [PATCH] core: improve error message when activating profile on device Before: $ nmcli connection up my-wired ifname eth0 Error: Connection activation failed: Connection 'my-wired' is not available on the device eth0 at this time. After: $ nmcli connection up my-wired ifname eth0 Error: Connection activation failed: Connection 'my-wired' is not available on device eth0 because device has no carrier --- src/nm-manager.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index f54d649ca4..4bb2e674c5 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4087,6 +4087,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * NMConnection *existing_connection = NULL; NMActiveConnection *master_ac = NULL; NMAuthSubject *subject; + GError *local = NULL; g_return_val_if_fail (NM_IS_MANAGER (self), FALSE); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (active), FALSE); @@ -4120,10 +4121,13 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * } /* Final connection must be available on device */ - if (!nm_device_check_connection_available (device, applied, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL, NULL)) { + if (!nm_device_check_connection_available (device, applied, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL, &local)) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION, - "Connection '%s' is not available on the device %s at this time.", - nm_settings_connection_get_id (connection), nm_device_get_iface (device)); + "Connection '%s' is not available on device %s because %s", + nm_settings_connection_get_id (connection), + nm_device_get_iface (device), + local->message); + g_error_free (local); return FALSE; }