From bbdf79191ae8d39d13af8124f922100dfe067f0b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 8 Sep 2022 11:00:12 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20traitement=20erreur=20upload=20?= =?UTF-8?q?photo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_photos.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index c7e2b59b..4863eaf7 100644 --- a/app/scodoc/sco_photos.py +++ b/app/scodoc/sco_photos.py @@ -62,7 +62,7 @@ from app.models import Identite from app.scodoc import sco_etud from app.scodoc import sco_portal_apogee from app.scodoc import sco_preferences -from app.scodoc.sco_exceptions import ScoGenError +from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.scolog import logdb import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu @@ -262,10 +262,11 @@ def store_photo(etud: dict, data, filename: str) -> tuple[bool, str]: return False, f"Fichier image '{filename}' de taille invalide ! ({filesize})" try: saved_filename = save_image(etud["etudid"], data) - except PIL.UnidentifiedImageError as exc: - raise ScoGenError( + except (OSError, PIL.UnidentifiedImageError) as exc: + raise ScoValueError( msg="Fichier d'image '{filename}' invalide ou format non supporté" ) from exc + # update database: etud["photo_filename"] = saved_filename etud["foto"] = None