Coverage for opt/mealie/lib/python3.12/site-packages/mealie/core/exceptions.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-11-25 15:48 +0000

1from sqlite3 import IntegrityError 1a

2 

3from mealie.lang.providers import Translator 1a

4 

5 

6class UnexpectedNone(Exception): 1a

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

8 

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

10 self.message = message 1bc

11 super().__init__(self.message) 1bc

12 

13 def __str__(self): 1a

14 return f"{self.message}" 1bc

15 

16 

17class PermissionDenied(Exception): 1a

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 1a

23 

24 

25class SlugError(Exception): 1a

26 """ 

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

28 """ 

29 

30 pass 1a

31 

32 

33class NoEntryFound(Exception): 1a

34 """ 

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

36 """ 

37 

38 pass 1a

39 

40 

41def mealie_registered_exceptions(t: Translator) -> dict: 1a

42 """ 

43 This function returns a dictionary of all the globally registered exceptions in the Mealie application. 

44 """ 

45 

46 return { 1dbefghijklmnopc

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): ... 1a

54 

55 

56class MissingClaimException(Exception): ... 1a