Coverage for src/robot_dispatch/services/errors.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-07 17:18 +0000

1from __future__ import annotations 

2 

3 

4class DomainError(Exception): 

5 """Base class for errors that map to a 4xx API response.""" 

6 

7 

8class TaskNotFound(DomainError): 

9 def __init__(self, task_id: object) -> None: 

10 self.task_id = task_id 

11 super().__init__(f"task {task_id} not found") 

12 

13 

14class RobotNotFound(DomainError): 

15 def __init__(self, robot_id: object) -> None: 

16 self.robot_id = robot_id 

17 super().__init__(f"robot {robot_id} not found") 

18 

19 

20class TaskConflict(DomainError): 

21 """The task exists but its current state forbids the operation.""" 

22 

23 def __init__(self, task_id: object, status: str, reason: str) -> None: 

24 self.task_id = task_id 

25 self.status = status 

26 self.reason = reason 

27 super().__init__(f"task {task_id} in status {status}: {reason}")