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

1from sqlite3 import IntegrityError 

2 

3from mealie.lang.providers import Translator 

4 

5 

6class UnexpectedNone(Exception): 

7 """Exception raised when a value is None when it should not be.""" 

8 

9 def __init__(self, message: str = "Unexpected None Value"): 

10 self.message = message 

11 super().__init__(self.message) 

12 

13 def __str__(self): 

14 return f"{self.message}" 

15 

16 

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 """ 

21 

22 pass 

23 

24 

25class SlugError(Exception): 

26 """ 

27 This exception is raised when the recipe name generates an invalid slug. 

28 """ 

29 

30 pass 

31 

32 

33class NoEntryFound(Exception): 

34 """ 

35 This exception is raised when a user tries to access a resource that does not exist. 

36 """ 

37 

38 pass 

39 

40 

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 """ 

45 

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 } 

51 

52 

53class UserLockedOut(Exception): ... 

54 

55 

56class MissingClaimException(Exception): ...