Skip to content

Add exceptions : Uniformisation des exceptions, typage, docstrings et commentaires - #50

Merged
raynaldlao merged 5 commits into
masterfrom
add-exceptions
Jul 24, 2026
Merged

Add exceptions : Uniformisation des exceptions, typage, docstrings et commentaires#50
raynaldlao merged 5 commits into
masterfrom
add-exceptions

Conversation

@raynaldlao

Copy link
Copy Markdown
Owner

Contexte

Uniformisation complète de la gestion des exceptions dans le projet.

Changements

exceptions.py — Nettoyage : suppression de 3 classes YAGNI (MissingEnvironmentVariableError, ViteManifestError, ExceptionTest). Ces exceptions étaient soit des chemins de crash au démarrage (jamais catchés), soit réservées aux tests. Remplacées par des builtins RuntimeError / Exception avec commentaires explicatifs.

Commentaires "Do not move to exceptions.py" — Ajoutés sur les 25 blocs except utilisant des exceptions de bibliothèques (Pydantic ValidationError, SQLAlchemy IntegrityError/SQLAlchemyError, Argon2 InvalidHashError/VerifyMismatchError) ou des builtins Python (TypeError, Exception). Chaque commentaire explique pourquoi l'exception reste en dehors de exceptions.py et interdit sa migration future.

…ngle root `exceptions.py`, removing per‑layer duplicates and avoiding DIP conflicts. Old application and infrastructure exception files are deleted along with their tests, the new unified module replaces them everywhere
…`, all ports and services now use typed exceptions instead of returning error strings, Flask adapters catch `BlogCommentError` via try/except, and all tests updated to use `pytest.raises` or `side_effect`. Modified files include the new root exception module, five input ports, four services, five Flask adapters and the corresponding service and infrastructure tests
… and bare ValueError/RuntimeError replaced with typed domain errors, SQLAlchemy adapter now raises AccountAlreadyExistsError and AccountNotFoundError with an inline logger and its duplicate Raises docstring entry is cleaned up, the in‑memory repo raises AccountNotFoundError, the Flask session adapter switches to `logging.getLogger(__name__)`
…s added, SQL adapters now use a shared SqlAlchemyBaseAdapter that maps SQLAlchemyError to DatabaseError, all config/utils/DTOs replace bare ValueError/RuntimeError with typed exceptions, CommentRequest.check_content_length gains a Raises docstring, three intentional broad except blocks in the Flask session adapter are documented, global LOG variables removed in favor of inline getLogger
…moved from `exceptions.py`, all remaining sites that intentionally use builtin or library exceptions now include a “Not in exceptions.py” comment, RuntimeError migration applied in env_config and template_helpers, TypeError usage documented in article_service and prosemirror_to_html, all Flask adapters annotated for ValidationError/Exception safety‑net blocks, SQLAlchemy and Argon2 adapters annotated for library exceptions, global LOG variables removed, tests updated to drop ExceptionTest
@raynaldlao
raynaldlao requested a review from hlargitte July 24, 2026 14:03
@raynaldlao raynaldlao self-assigned this Jul 24, 2026

@hlargitte hlargitte left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@raynaldlao
raynaldlao merged commit 96b92ea into master Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants