Coverage for dataexcept/exceptions/external.py: 93%

26 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-09-03 20:46 +0000

1from .base import JobError 

2 

3 

4class ServiceConnectionError(JobError): 

5 """Raised when a connection to an external service fails.""" 

6 

7 def __init__(self, service_name: str, original_exception: Exception | None = None): 

8 self.service_name = service_name 

9 self.original_exception = original_exception 

10 msg = f"Failed to connect to service '{service_name}'" 

11 if original_exception: 11 ↛ 12line 11 didn't jump to line 12 because the condition on line 11 was never true

12 msg += f": {original_exception}" 

13 super().__init__(msg) 

14 

15 

16class OperationTimeoutError(JobError): 

17 """Raised when an operation exceeds its time limit.""" 

18 

19 def __init__(self, operation: str, timeout: float): 

20 self.operation = operation 

21 self.timeout = timeout 

22 msg = f"Operation '{operation}' timed out after {timeout} seconds" 

23 super().__init__(msg) 

24 

25 

26class ResourceNotFoundError(JobError): 

27 """Raised when a required resource cannot be found.""" 

28 

29 def __init__(self, resource_type: str, identifier: str): 

30 self.resource_type = resource_type 

31 self.identifier = identifier 

32 msg = f"{resource_type} with identifier '{identifier}' not found" 

33 super().__init__(msg) 

34 

35 

36class DependencyError(JobError): 

37 """Raised when a job dependency is missing or fails.""" 

38 

39 def __init__(self, dependency_name: str, message: str | None = None): 

40 self.dependency_name = dependency_name 

41 self.message = message or f"Dependency '{dependency_name}' error" 

42 super().__init__(self.message)