error in external function should returns only ConfigError
This commit is contained in:
parent
80f6f4ba03
commit
5bf75b3824
@ -1,3 +1,7 @@
|
||||
Sun Feb 12 10:30:13 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* error in external function should returns explicit error message
|
||||
all errors will be ConfigError
|
||||
|
||||
Thu Jan 12 19:49:41 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* can mix inversed and non inversed requires
|
||||
* validator's function can have 1 arg, 2 args or 3 args without
|
||||
|
@ -993,9 +993,9 @@ def test_callback_raise():
|
||||
cfg.read_write()
|
||||
try:
|
||||
cfg.od1.opt1
|
||||
except Exception, err:
|
||||
except ConfigError, err:
|
||||
assert '"Option 1"' in str(err)
|
||||
try:
|
||||
cfg.od2.opt2
|
||||
except ValueError, err:
|
||||
except ConfigError, err:
|
||||
assert '"Option 2"' in str(err)
|
||||
|
@ -7,7 +7,7 @@ from py.test import raises
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import BoolOption, StrOption, OptionDescription
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.error import ValueWarning
|
||||
from tiramisu.error import ValueWarning, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ def test_validator_params_value_values_index_slave():
|
||||
|
||||
|
||||
def test_validator_params_value_values_notmulti():
|
||||
raises(TypeError, "opt1 = StrOption('opt1', '', validator=value_values, default='val')")
|
||||
raises(ConfigError, "opt1 = StrOption('opt1', '', validator=value_values, default='val')")
|
||||
|
||||
|
||||
def test_validator_params_value_values_kwargs_empty():
|
||||
@ -286,7 +286,7 @@ def test_validator_params_context():
|
||||
|
||||
def test_validator_params_key():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'param': ('yes',)}, default='val')
|
||||
raises(TypeError, "StrOption('opt2', '', validator=return_true, validator_params={'param_unknown': ('yes',)}, default='val')")
|
||||
raises(ConfigError, "StrOption('opt2', '', validator=return_true, validator_params={'param_unknown': ('yes',)}, default='val')")
|
||||
root = OptionDescription('root', '', [opt1])
|
||||
cfg = Config(root)
|
||||
assert cfg.opt1 == 'val'
|
||||
|
@ -260,6 +260,16 @@ def calculate(option, callback, is_validator, args, kwargs):
|
||||
error = err
|
||||
except Exception as err:
|
||||
error = err
|
||||
raise error.__class__(_('function "{0}" returns "{1}" for option "{2}"').format(callback.func_name,
|
||||
option.impl_get_display_name(),
|
||||
str(err)))
|
||||
if len(args) != 0 or len(kwargs) != 0:
|
||||
msg = _('unexpected error "{0}" in function "{1}" with arguments "{3}" and "{4}" '
|
||||
'for option "{2}"').format(str(error),
|
||||
callback.func_name,
|
||||
option.impl_get_display_name(),
|
||||
args,
|
||||
kwargs)
|
||||
else:
|
||||
msg = _('unexpected error "{0}" in function "{1}" for option "{2}"'
|
||||
'').format(str(error),
|
||||
callback.func_name,
|
||||
option.impl_get_display_name())
|
||||
raise ConfigError(msg)
|
||||
|
@ -2,7 +2,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Tiramisu\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-02-11 18:05+0100\n"
|
||||
"POT-Creation-Date: 2017-02-12 10:35+0100\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: Emmanuel Garette <egarette@cadoles.com>\n"
|
||||
"Language-Team: Tiramisu's team <egarette@cadoles.com>\n"
|
||||
@ -26,9 +26,18 @@ msgid "callback cannot return a list for a slave option ({0})"
|
||||
msgstr ""
|
||||
"un calcul ne peut pas retourner une liste pour une option esclave ({0})"
|
||||
|
||||
#: tiramisu/autolib.py:263
|
||||
msgid "function \"{0}\" returns \"{1}\" for option \"{2}\""
|
||||
msgstr "la fonction \"{0}\" retourne \"{1}\" pour l'option \"{2}\""
|
||||
#: tiramisu/autolib.py:264
|
||||
msgid ""
|
||||
"unexpected error \"{0}\" in function \"{1}\" with arguments \"{3}\" and "
|
||||
"\"{4}\" for option \"{2}\""
|
||||
msgstr ""
|
||||
"erreur inattendue \"{0}\" dans la fonction \"{1}\" avec les arguments "
|
||||
"\"{3}\" et \"{4}\" pour l'option \"{2}\""
|
||||
|
||||
#: tiramisu/autolib.py:271
|
||||
msgid "unexpected error \"{0}\" in function \"{1}\" for option \"{2}\""
|
||||
msgstr ""
|
||||
"erreur inattendue \"{0}\" dans la fonction \"{1}\" pour l'option \"{2}\""
|
||||
|
||||
#: tiramisu/config.py:64
|
||||
msgid "descr must be an optiondescription, not {0}"
|
||||
@ -931,6 +940,9 @@ msgstr "ne peut étendre une option multi {0} pour une maître ou une esclave"
|
||||
msgid "cannot pop a value on a multi option {0} which is a slave"
|
||||
msgstr "ne peut supprimer une valeur dans l'option multi {0} qui est esclave"
|
||||
|
||||
#~ msgid "function \"{0}\" returns \"{1}\" for option \"{2}\""
|
||||
#~ msgstr "la fonction \"{0}\" retourne \"{1}\" pour l'option \"{2}\""
|
||||
|
||||
#~ msgid "not allowed default value for option {0} in group {1}"
|
||||
#~ msgstr "valeur de défaut non autorisée pour l'option {0} du groupe {1}"
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2017-02-11 18:04+CET\n"
|
||||
"POT-Creation-Date: 2017-02-12 10:34+CET\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -23,8 +23,12 @@ msgstr ""
|
||||
msgid "callback cannot return a list for a slave option ({0})"
|
||||
msgstr ""
|
||||
|
||||
#: tiramisu/autolib.py:263
|
||||
msgid "function \"{0}\" returns \"{1}\" for option \"{2}\""
|
||||
#: tiramisu/autolib.py:264
|
||||
msgid "unexpected error \"{0}\" in function \"{1}\" with arguments \"{3}\" and \"{4}\" for option \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: tiramisu/autolib.py:271
|
||||
msgid "unexpected error \"{0}\" in function \"{1}\" for option \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: tiramisu/config.py:64
|
||||
|
Loading…
Reference in New Issue
Block a user