mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 12:38:10 +02:00
cli: improve error message for device not found
$ nmcli connection add type ethernet con-name x autoconnect no ipv4.method disabled ipv6.method disabled $ nmcli connection up x ifname bogus Error: device 'bogus' not compatible with connection 'x'. Better would be: Error: device 'bogus' not found for connection 'x'.
This commit is contained in:
parent
409c87af2c
commit
bb3c93bfd4
1 changed files with 19 additions and 8 deletions
|
|
@ -2488,8 +2488,9 @@ find_device_for_connection(NmCli * nmc,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Other connections */
|
/* Other connections */
|
||||||
NMDevice * found_device = NULL;
|
NMDevice * found_device = NULL;
|
||||||
const GPtrArray *devices = nm_client_get_devices(nmc->client);
|
const GPtrArray *devices = nm_client_get_devices(nmc->client);
|
||||||
|
gboolean found_device_with_name = FALSE;
|
||||||
|
|
||||||
for (i = 0; i < devices->len && !found_device; i++) {
|
for (i = 0; i < devices->len && !found_device; i++) {
|
||||||
NMDevice *dev = g_ptr_array_index(devices, i);
|
NMDevice *dev = g_ptr_array_index(devices, i);
|
||||||
|
|
@ -2499,6 +2500,7 @@ find_device_for_connection(NmCli * nmc,
|
||||||
if (!nm_streq0(dev_iface, iface))
|
if (!nm_streq0(dev_iface, iface))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
found_device_with_name = TRUE;
|
||||||
if (!nm_device_connection_compatible(dev, connection, error)) {
|
if (!nm_device_connection_compatible(dev, connection, error)) {
|
||||||
g_prefix_error(error,
|
g_prefix_error(error,
|
||||||
_("device '%s' not compatible with connection '%s': "),
|
_("device '%s' not compatible with connection '%s': "),
|
||||||
|
|
@ -2535,12 +2537,21 @@ find_device_for_connection(NmCli * nmc,
|
||||||
|
|
||||||
if (!found_device) {
|
if (!found_device) {
|
||||||
if (iface) {
|
if (iface) {
|
||||||
g_set_error(error,
|
if (found_device_with_name) {
|
||||||
NMCLI_ERROR,
|
g_set_error(error,
|
||||||
0,
|
NMCLI_ERROR,
|
||||||
_("device '%s' not compatible with connection '%s'"),
|
0,
|
||||||
iface,
|
_("device '%s' not compatible with connection '%s'"),
|
||||||
nm_setting_connection_get_id(s_con));
|
iface,
|
||||||
|
nm_setting_connection_get_id(s_con));
|
||||||
|
} else {
|
||||||
|
g_set_error(error,
|
||||||
|
NMCLI_ERROR,
|
||||||
|
0,
|
||||||
|
_("device '%s' not found for connection '%s'"),
|
||||||
|
iface,
|
||||||
|
nm_setting_connection_get_id(s_con));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
NMCLI_ERROR,
|
NMCLI_ERROR,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue