form: parse pydantic error in logging

This commit is contained in:
axolotle 2023-04-24 15:12:54 +02:00
parent 51d302bf18
commit 2f4c88ec55

View file

@ -1537,7 +1537,11 @@ def prompt_or_validate_form(
except (ValidationError, YunohostValidationError) as e:
# If in interactive cli, re-ask the current question
if i < MAX_RETRIES and interactive:
logger.error(str(e))
logger.error(
"\n".join([err["msg"] for err in e.errors()])
if isinstance(e, ValidationError)
else str(e)
)
value = None
continue
@ -1627,8 +1631,7 @@ def parse_raw_options(
model = OptionsModel(**raw_options)
except ValidationError as e:
error = "\n".join([err["msg"] for err in e.errors()])
# FIXME use YunohostError instead since it is not really a user mistake?
raise YunohostValidationError(error, raw_msg=True)
raise YunohostError(error, raw_msg=True)
model.translate_options()