Coverage for opt/mealie/lib/python3.12/site-packages/mealie/core/exceptions.py: 100%
18 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 03:04 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 03:04 +0000
1from sqlite3 import IntegrityError
3from mealie.lang.providers import Translator
6class UnexpectedNone(Exception):
7 """Exception raised when a value is None when it should not be."""
9 def __init__(self, message: str = "Unexpected None Value"):
10 self.message = message
11 super().__init__(self.message)
13 def __str__(self):
14 return f"{self.message}"
17class PermissionDenied(Exception):
18 """
19 This exception is raised when a user tries to access a resource that they do not have permission to access.
20 """
22 pass
25class SlugError(Exception):
26 """
27 This exception is raised when the recipe name generates an invalid slug.
28 """
30 pass
33class NoEntryFound(Exception):
34 """
35 This exception is raised when a user tries to access a resource that does not exist.
36 """
38 pass
41def mealie_registered_exceptions(t: Translator) -> dict:
42 """
43 This function returns a dictionary of all the globally registered exceptions in the Mealie application.
44 """
46 return {
47 PermissionDenied: t.t("exceptions.permission-denied"),
48 NoEntryFound: t.t("exceptions.no-entry-found"),
49 IntegrityError: t.t("exceptions.integrity-error"),
50 }
53class UserLockedOut(Exception): ...
56class MissingClaimException(Exception): ...