Coverage for lintro / ai / exceptions.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""AI-specific exception hierarchy for Lintro. 

2 

3All exceptions inherit from LintroError to maintain a consistent 

4exception hierarchy across the project. 

5""" 

6 

7from __future__ import annotations 

8 

9from lintro.exceptions.errors import LintroError 

10 

11 

12class AIError(LintroError): 

13 """Base exception for all AI-related errors.""" 

14 

15 

16class AINotAvailableError(AIError): 

17 """AI dependencies are not installed. 

18 

19 Raised when AI features are requested but the required packages 

20 (anthropic, openai) are not available. The error message includes 

21 installation instructions. 

22 """ 

23 

24 

25class AIProviderError(AIError): 

26 """Error communicating with an AI provider. 

27 

28 Raised for general API communication failures such as network 

29 errors, server errors, or unexpected response formats. 

30 """ 

31 

32 

33class AIAuthenticationError(AIProviderError): 

34 """API key is invalid or missing. 

35 

36 Raised when the provider rejects the API key or when no API key 

37 can be found in the expected environment variable. 

38 """ 

39 

40 

41class AIRateLimitError(AIProviderError): 

42 """Rate limit exceeded on the AI provider. 

43 

44 Raised when the provider returns a rate limit error. Users should 

45 wait and retry, or switch to a different provider/model. 

46 """