mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] reintroduce custom exceptions for input fields type
This commit is contained in:
parent
ecb52b4f11
commit
49b9146065
1 changed files with 17 additions and 2 deletions
|
@ -2434,8 +2434,7 @@ class YunoHostArgumentFormatParser(object):
|
||||||
# we have an answer, do some post checks
|
# we have an answer, do some post checks
|
||||||
if question.value is not None:
|
if question.value is not None:
|
||||||
if question.choices and question.value not in question.choices:
|
if question.choices and question.value not in question.choices:
|
||||||
raise YunohostError('app_argument_choice_invalid', name=question.name,
|
self._raise_invalide_answer(question)
|
||||||
choices=', '.join(question.choices))
|
|
||||||
|
|
||||||
# this is done to enforce a certain formating like for boolean
|
# this is done to enforce a certain formating like for boolean
|
||||||
# by default it doesn't do anything
|
# by default it doesn't do anything
|
||||||
|
@ -2443,6 +2442,10 @@ class YunoHostArgumentFormatParser(object):
|
||||||
|
|
||||||
return (question.value, self.argument_type)
|
return (question.value, self.argument_type)
|
||||||
|
|
||||||
|
def _raise_invalide_answer(self, question):
|
||||||
|
raise YunohostError('app_argument_choice_invalid', name=question.name,
|
||||||
|
choices=', '.join(question.choices))
|
||||||
|
|
||||||
def _format_text_for_user_input_in_cli(self, question):
|
def _format_text_for_user_input_in_cli(self, question):
|
||||||
text_for_user_input_in_cli = _value_for_locale(question.ask)
|
text_for_user_input_in_cli = _value_for_locale(question.ask)
|
||||||
|
|
||||||
|
@ -2534,6 +2537,10 @@ class DomainArgumentParser(YunoHostArgumentFormatParser):
|
||||||
|
|
||||||
return question
|
return question
|
||||||
|
|
||||||
|
def _raise_invalide_answer(self, question):
|
||||||
|
raise YunohostError('app_argument_invalid', name=question.name,
|
||||||
|
error=m18n.n('domain_unknown'))
|
||||||
|
|
||||||
|
|
||||||
class UserArgumentParser(YunoHostArgumentFormatParser):
|
class UserArgumentParser(YunoHostArgumentFormatParser):
|
||||||
argument_type = "user"
|
argument_type = "user"
|
||||||
|
@ -2546,6 +2553,10 @@ class UserArgumentParser(YunoHostArgumentFormatParser):
|
||||||
|
|
||||||
return question
|
return question
|
||||||
|
|
||||||
|
def _raise_invalide_answer(self, question):
|
||||||
|
raise YunohostError('app_argument_invalid', name=question.name,
|
||||||
|
error=m18n.n('user_unknown', user=question.value))
|
||||||
|
|
||||||
|
|
||||||
class AppArgumentParser(YunoHostArgumentFormatParser):
|
class AppArgumentParser(YunoHostArgumentFormatParser):
|
||||||
argument_type = "app"
|
argument_type = "app"
|
||||||
|
@ -2558,6 +2569,10 @@ class AppArgumentParser(YunoHostArgumentFormatParser):
|
||||||
|
|
||||||
return question
|
return question
|
||||||
|
|
||||||
|
def _raise_invalide_answer(self, question):
|
||||||
|
raise YunohostError('app_argument_invalid', name=question.name,
|
||||||
|
error=m18n.n('app_unknown'))
|
||||||
|
|
||||||
|
|
||||||
class DisplayTextArgumentParser(YunoHostArgumentFormatParser):
|
class DisplayTextArgumentParser(YunoHostArgumentFormatParser):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue