From 329781989244002730f9866f42b4b037671becb5 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Tue, 28 Jun 2022 16:02:15 +0200 Subject: [PATCH] gestion d'erreurs pour la route formsemestre_apo --- app/api/formsemestres.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index bdcb46164..c086b6278 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -7,6 +7,7 @@ import app from app import models from app.api import bp from app.api.auth import token_auth, token_permission_required +from app.api.errors import error_response from app.comp import res_sem from app.comp.moy_mod import ModuleImplResults from app.comp.res_compat import NotesTableCompat @@ -91,7 +92,13 @@ def formsemestre_apo(etape_apo: str): FormSemestreEtape.formsemestre_id == FormSemestre.id, ) - return jsonify([formsemestre.to_dict() for formsemestre in formsemestres]) + res = [formsemestre.to_dict() for formsemestre in formsemestres] + if len(res) == 0: + return error_response( + 404, message="Aucun formsemestre trouvé avec cette étape apogée" + ) + else: + return jsonify(res) @bp.route("/formsemestre//bulletins", methods=["GET"])