diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index c7e2b59bf..4863eaf7e 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