From 000e0169859c165485f94c4d1665361b9a86a57a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 19 May 2024 22:53:54 +0200 Subject: [PATCH] Enhance critical_error handling. --- app/__init__.py | 8 +++----- app/email.py | 14 +++++++++++--- sco_version.py | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 6a1ea6d0..d6e0be82 100755 --- a/app/__init__.py +++ b/app/__init__.py @@ -637,14 +637,12 @@ def critical_error(msg): import app.scodoc.sco_utils as scu log(f"\n*** CRITICAL ERROR: {msg}") - send_scodoc_alarm(f"CRITICAL ERROR: {msg}", msg) + subject = f"CRITICAL ERROR: {msg}".strip()[:68] + send_scodoc_alarm(subject, msg) clear_scodoc_cache() raise ScoValueError( f""" - Une erreur est survenue. - - Si le problème persiste, merci de contacter le support ScoDoc via - {scu.SCO_DISCORD_ASSISTANCE} + Une erreur est survenue, veuillez ré-essayer. {msg} """ diff --git a/app/email.py b/app/email.py index 5efe838f..d4e87fad 100644 --- a/app/email.py +++ b/app/email.py @@ -9,9 +9,9 @@ import datetime from threading import Thread from flask import current_app, g -from flask_mail import Message +from flask_mail import BadHeaderError, Message -from app import mail +from app import log, mail from app.models.departements import Departement from app.models.config import ScoDocSiteConfig from app.scodoc import sco_preferences @@ -20,7 +20,15 @@ from app.scodoc import sco_preferences def send_async_email(app, msg): "Send an email, async" with app.app_context(): - mail.send(msg) + try: + mail.send(msg) + except BadHeaderError: + log( + f"""send_async_email: BadHeaderError + msg={msg} + """ + ) + raise def send_email( diff --git a/sco_version.py b/sco_version.py index 67362a1a..4675621d 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.966" +SCOVERSION = "9.6.967" SCONAME = "ScoDoc" @@ -14,7 +14,7 @@ SCONEWS = """
  • Nouveaux bulletins BUT compacts
  • Nouvelle gestion des absences et assiduité
  • Mise à jour logiciels: Debian 12, Python 3.11, ...
  • -
  • Evaluations bonus
  • +
  • Évaluations bonus
  • ScoDoc 9.5 (juillet 2023)