Coverage for webapp/api/exceptions.py: 88%

16 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-28 22:05 +0000

1class ApiError(Exception): 

2 """ 

3 Base exception for any errors in the API layer 

4 """ 

5 

6 pass 

7 

8 

9class ApiConnectionError(ApiError): 

10 """ 

11 Communication with the API failed 

12 """ 

13 

14 pass 

15 

16 

17class ApiTimeoutError(ApiError): 

18 """ 

19 Communication with the API timed out 

20 """ 

21 

22 pass 

23 

24 

25class ApiResponseDecodeError(ApiError): 

26 """ 

27 We failed to properly decode the response from the API 

28 """ 

29 

30 pass 

31 

32 

33class ApiResponseError(ApiError): 

34 """ 

35 The API responded with an error 

36 """ 

37 

38 def __init__(self, message, status_code): 

39 self.status_code = status_code 

40 return super().__init__(message) 

41 

42 

43class ApiResponseErrorList(ApiResponseError): 

44 """ 

45 The API responded with a list of errors, 

46 which are included in self.errors 

47 """ 

48 

49 def __init__(self, message, status_code, errors): 

50 self.errors = errors 

51 return super().__init__(message, status_code)