Coverage for src/rok4/exceptions.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-01 15:35 +0000

1class MissingAttributeError(Exception): 

2 """ 

3 Exception raised when an attribute is missing in a file 

4 """ 

5 

6 def __init__(self, path, missing): 

7 self.path = path 

8 self.missing = missing 

9 super().__init__(f"Missing attribute {missing} in '{path}'") 

10 

11 

12class MissingEnvironmentError(Exception): 

13 """ 

14 Exception raised when a needed environment variable is not defined 

15 """ 

16 

17 def __init__(self, missing): 

18 self.missing = missing 

19 super().__init__(f"Missing environment variable {missing}") 

20 

21 

22class StorageError(Exception): 

23 """ 

24 Exception raised when an issue occured when using a storage 

25 """ 

26 

27 def __init__(self, type, issue): 

28 self.type = type 

29 self.issue = issue 

30 super().__init__(f"Issue occured using a {type} storage : {issue}") 

31 

32 

33class FormatError(Exception): 

34 """ 

35 Exception raised when a format is expected but not respected 

36 """ 

37 

38 def __init__(self, expected_format, content, issue): 

39 self.expected_format = expected_format 

40 self.content = content 

41 self.issue = issue 

42 super().__init__(f"Expected format {expected_format} to read '{content}' : {issue}")