better error message

This commit is contained in:
Emmanuel Garette 2017-06-16 18:25:01 +02:00
parent 9b78f46e9d
commit a2dc793be6
2 changed files with 6 additions and 9 deletions

View file

@ -235,12 +235,9 @@ class IPOption(Option):
return
ip, network, netmask = vals
if IP(ip) not in IP('{0}/{1}'.format(network, netmask)):
if warnings_only:
msg = _('should be in network {0}/{1} ({2}/{3})')
else:
msg = _('must be in network {0}/{1} ({2}/{3})')
msg = _('{4} is not in network {0}/{1} ({2}/{3})')
return ValueError(msg.format(network, netmask,
opts[1].impl_getname(), opts[2].impl_getname()))
opts[1].impl_getname(), opts[2].impl_getname(), ip))
# test if ip is not network/broadcast IP
return opts[2]._cons_ip_netmask(current_opt, (opts[2], opts[0]), (netmask, ip), warnings_only)
@ -437,8 +434,8 @@ class BroadcastOption(Option):
return
broadcast, network, netmask = vals
if IP('{0}/{1}'.format(network, netmask)).broadcast() != IP(broadcast):
return ValueError(_('with network {0}/{1} ({2}/{3})').format(
network, netmask, opts[1].impl_getname(), opts[2].impl_getname()))
return ValueError(_('broadcast {4} invalid with network {0}/{1} ({2}/{3})').format(
network, netmask, opts[1].impl_getname(), opts[2].impl_getname(), broadcast))
class DomainnameOption(Option):
@ -524,7 +521,7 @@ class DomainnameOption(Option):
except ValueError:
pass
else:
raise ValueError(_('must not be an IP'))
return ValueError(_('must not be an IP'))
part_name_length = self._get_len(self._get_extra('_dom_type'))
if self._get_extra('_dom_type') == 'domainname':
if not self._get_extra('_allow_without_dot') and not "." in value:

View file

@ -675,7 +675,7 @@ class Values(object):
if ret is not None:
yield ret
descr = self._getcontext().cfgimpl_get_description()
descr = context.cfgimpl_get_description()
for path in _mandatory_warnings(descr):
yield path