Add exceptions : Uniformisation des exceptions, typage, docstrings et commentaires - #50
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 builtinsRuntimeError/Exceptionavec commentaires explicatifs.Commentaires "Do not move to exceptions.py" — Ajoutés sur les 25 blocs
exceptutilisant des exceptions de bibliothèques (PydanticValidationError, SQLAlchemyIntegrityError/SQLAlchemyError, Argon2InvalidHashError/VerifyMismatchError) ou des builtins Python (TypeError,Exception). Chaque commentaire explique pourquoi l'exception reste en dehors deexceptions.pyet interdit sa migration future.