better propertyerror message
This commit is contained in:
@ -24,9 +24,10 @@ import warnings
|
||||
import sys
|
||||
|
||||
from ..i18n import _
|
||||
from ..setting import log, undefined
|
||||
from ..setting import log, undefined, debug
|
||||
from ..autolib import carry_out_calculation
|
||||
from ..error import ConfigError, ValueWarning, PropertiesOptionError
|
||||
from ..error import (ConfigError, ValueWarning, PropertiesOptionError,
|
||||
display_list)
|
||||
from ..storage import get_storages_option
|
||||
|
||||
|
||||
@ -38,13 +39,6 @@ forbidden_names = frozenset(['iter_all', 'iter_group', 'find', 'find_first',
|
||||
'read_write', 'getowner', 'set_contexts'])
|
||||
|
||||
|
||||
def display_list(list_):
|
||||
if len(list_) == 1:
|
||||
return list_[0]
|
||||
else:
|
||||
return ', '.join(list_[:-1]) + _(' and ') + list_[-1]
|
||||
|
||||
|
||||
def valid_name(name):
|
||||
"an option's name is a str and does not start with 'impl' or 'cfgimpl'"
|
||||
if not isinstance(name, str): # pragma: optional cover
|
||||
@ -417,7 +411,8 @@ class Option(OnlyOption):
|
||||
returns_raise=True)
|
||||
if isinstance(opt_value, Exception):
|
||||
if isinstance(opt_value, PropertiesOptionError):
|
||||
log.debug('propertyerror in _launch_consistency: {0}'.format(opt_value))
|
||||
if debug:
|
||||
log.debug('propertyerror in _launch_consistency: {0}'.format(opt_value))
|
||||
if transitive:
|
||||
return opt_value
|
||||
else:
|
||||
@ -493,10 +488,11 @@ class Option(OnlyOption):
|
||||
err = self._validate(_value, context, current_opt,
|
||||
returns_raise=True)
|
||||
if err:
|
||||
log.debug('do_validation: value: {0}, index: {1}, '
|
||||
'submulti_index: {2}'.format(_value, _index,
|
||||
submulti_index),
|
||||
exc_info=True)
|
||||
if debug:
|
||||
log.debug('do_validation: value: {0}, index: {1}, '
|
||||
'submulti_index: {2}'.format(_value, _index,
|
||||
submulti_index),
|
||||
exc_info=True)
|
||||
err_msg = '{0}'.format(err)
|
||||
if err_msg:
|
||||
msg = _('{0} is an invalid {1} for option {2}, {3}'
|
||||
@ -512,8 +508,9 @@ class Option(OnlyOption):
|
||||
if not error:
|
||||
error = self._second_level_validation(_value, self._is_warnings_only())
|
||||
if error:
|
||||
log.debug(_('do_validation for {0}: error in value').format(
|
||||
self.impl_getname()), exc_info=True)
|
||||
if debug:
|
||||
log.debug(_('do_validation for {0}: error in value').format(
|
||||
self.impl_getname()), exc_info=True)
|
||||
if self._is_warnings_only():
|
||||
warning = error
|
||||
error = None
|
||||
@ -718,7 +715,8 @@ class Option(OnlyOption):
|
||||
msg = _("value for {0} and {1} should be different")
|
||||
else:
|
||||
msg = _("value for {0} and {1} must be different")
|
||||
log.debug('_cons_not_equal: {0} and {1} are not different'.format(val_inf, val_sup))
|
||||
if debug:
|
||||
log.debug('_cons_not_equal: {0} and {1} are not different'.format(val_inf, val_sup))
|
||||
return ValueError(msg.format(opts[idx_inf].impl_getname(),
|
||||
opts[idx_inf + idx_sup + 1].impl_getname()))
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
from ..i18n import _
|
||||
from ..setting import log, undefined
|
||||
from ..setting import log, undefined, debug
|
||||
from ..error import SlaveError, PropertiesOptionError
|
||||
from .baseoption import DynSymLinkOption, SymLinkOption, Option
|
||||
|
||||
@ -278,8 +278,9 @@ class MasterSlaves(object):
|
||||
|
||||
def validate_slave_length(self, masterlen, valuelen, name, opt, setitem=False):
|
||||
if valuelen > masterlen or (valuelen < masterlen and setitem): # pragma: optional cover
|
||||
log.debug('validate_slave_length: masterlen: {0}, valuelen: {1}, '
|
||||
'setitem: {2}'.format(masterlen, valuelen, setitem))
|
||||
if debug:
|
||||
log.debug('validate_slave_length: masterlen: {0}, valuelen: {1}, '
|
||||
'setitem: {2}'.format(masterlen, valuelen, setitem))
|
||||
raise SlaveError(_("invalid len for the slave: {0}"
|
||||
" which has {1} as master").format(
|
||||
name, self.getmaster(opt).impl_getname()))
|
||||
|
Reference in New Issue
Block a user