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

10 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-14 15:56 +0000

1""" 

2Custom exceptions for xrayradar 

3 

4All exceptions inherit from ErrorTrackerException and provide clear, 

5actionable error messages to help users resolve issues quickly. 

6""" 

7 

8 

9class ErrorTrackerException(Exception): 

10 """ 

11 Base exception for all error tracker SDK errors 

12  

13 All xrayradar-specific exceptions inherit from this class, 

14 making it easy to catch all SDK-related errors. 

15 """ 

16 pass 

17 

18 

19class ConfigurationError(ErrorTrackerException): 

20 """ 

21 Raised when there's a configuration error 

22  

23 This typically indicates an issue with how the SDK is configured, 

24 such as an invalid DSN format or missing required parameters. 

25  

26 Example: 

27 >>> raise ConfigurationError("DSN is required but not provided") 

28 """ 

29 pass 

30 

31 

32class TransportError(ErrorTrackerException): 

33 """ 

34 Raised when there's an error sending data to the XrayRadar server 

35  

36 This indicates a network or server-side issue preventing event delivery. 

37 The SDK will include details about the failure in the error message. 

38  

39 Example: 

40 >>> raise TransportError("Failed to send event: HTTP 500: Internal Server Error") 

41 """ 

42 pass 

43 

44 

45class RateLimitedError(TransportError): 

46 """ 

47 Raised when the client is rate limited by the XrayRadar server 

48  

49 The server has temporarily limited requests. The error message includes 

50 the retry-after time. You should wait before sending more events. 

51  

52 Example: 

53 >>> raise RateLimitedError("Rate limited. Retry after 60 seconds") 

54 """ 

55 pass 

56 

57 

58class InvalidDsnError(ConfigurationError): 

59 """ 

60 Raised when the DSN (Data Source Name) is invalid or malformed 

61  

62 The DSN format should be: https://xrayradar.com/your_project_id 

63 Make sure you've copied the correct DSN from your XrayRadar project settings. 

64  

65 Example: 

66 >>> raise InvalidDsnError("Invalid DSN format: https://example.com") 

67 """ 

68 pass