From a2dc793be6fff0a62bc6719252435672f1a66e15 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 16 Jun 2017 18:25:01 +0200 Subject: [PATCH] better error message --- tiramisu/option/option.py | 13 +++++-------- tiramisu/value.py | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tiramisu/option/option.py b/tiramisu/option/option.py index 619b2c0..90634ae 100644 --- a/tiramisu/option/option.py +++ b/tiramisu/option/option.py @@ -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: diff --git a/tiramisu/value.py b/tiramisu/value.py index 8406071..a16beff 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -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