Coverage for src/data_api/core/exceptions.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-11-13 19:28 +0000

1""" 

2Custom exceptions for the application. 

3""" 

4 

5INTERNAL_ERROR_DETAIL = "Internal server error" 

6 

7 

8class DataAPIException(Exception): 

9 """Base exception for all Data API errors.""" 

10 

11 pass 

12 

13 

14class DataNotAvailableException(DataAPIException): 

15 """Raised when requested data is not available.""" 

16 

17 pass 

18 

19 

20class DataUpdateException(DataAPIException): 

21 """Raised when data update fails.""" 

22 

23 pass 

24 

25 

26class UpstreamException(DataAPIException): 

27 """A live upstream failure with a safe public response.""" 

28 

29 status_code = 502 

30 detail = "Upstream service unavailable" 

31 

32 

33class UpstreamTimeoutException(UpstreamException): 

34 """Raised when a live upstream request times out.""" 

35 

36 status_code = 504 

37 detail = "Upstream request timed out" 

38 

39 

40class UpstreamResponseException(UpstreamException): 

41 """Raised when a live upstream response cannot be parsed or validated.""" 

42 

43 detail = "Invalid response from upstream service"