From 5b76654b7b7408f1115b02d6dc47ab9347a75f8d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 5 Sep 2023 21:49:10 +0200 Subject: [PATCH] Enhance error handling in scodoc7 decorator. --- app/decorators.py | 5 ++++- app/templates/sco_value_error.j2 | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/decorators.py b/app/decorators.py index 08aea4f73..d8816d618 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -186,7 +186,10 @@ def scodoc7func(func): arg_names = argspec.args for arg_name in arg_names: # pour chaque arg de la fonction vue # peut produire une KeyError s'il manque un argument attendu: - v = req_args[arg_name] + try: + v = req_args[arg_name] + except KeyError as exc: + raise ScoValueError(f"argument {arg_name} manquant") from exc # try to convert all arguments to INTEGERS # necessary for db ids and boolean values try: diff --git a/app/templates/sco_value_error.j2 b/app/templates/sco_value_error.j2 index 94b603101..e9dbd86f9 100644 --- a/app/templates/sco_value_error.j2 +++ b/app/templates/sco_value_error.j2 @@ -15,4 +15,11 @@ {% endif %}

+

+Si le problème persiste, merci de contacter le support ScoDoc via + +{{scu.SCO_DISCORD_ASSISTANCE}} + +

+ {% endblock %} \ No newline at end of file