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

16 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-05 22:06 +0000

1"""Custom exceptions for ai-shell.""" 

2 

3 

4class AiShellError(Exception): 

5 """Base exception for ai-shell.""" 

6 

7 

8class DockerNotAvailableError(AiShellError): 

9 """Docker daemon is not running or not installed.""" 

10 

11 

12class ImagePullError(AiShellError): 

13 """Failed to pull Docker image.""" 

14 

15 def __init__(self, image: str, reason: str) -> None: 

16 self.image = image 

17 self.reason = reason 

18 super().__init__(f"Failed to pull {image}: {reason}") 

19 

20 

21class ContainerNotFoundError(AiShellError): 

22 """Container does not exist.""" 

23 

24 def __init__(self, name: str) -> None: 

25 self.name = name 

26 super().__init__(f"Container '{name}' not found") 

27 

28 

29class ConfigError(AiShellError): 

30 """Invalid configuration.""" 

31 

32 

33class GpuRequiredError(AiShellError): 

34 """A container that requires an NVIDIA GPU was requested without one.""" 

35 

36 def __init__(self, service: str) -> None: 

37 self.service = service 

38 super().__init__( 

39 f"{service} requires an NVIDIA GPU (no CPU-only image is available). " 

40 f"Install NVIDIA drivers + the NVIDIA Container Toolkit and retry." 

41 )