Spaces:
Sleeping
Sleeping
| """Shared domain errors mapped to HTTP responses in the API layer.""" | |
| class DomainError(Exception): | |
| """Base for errors that map to a specific HTTP status.""" | |
| class BaselineExistsError(DomainError): | |
| def __init__(self, existing_version_id: int): | |
| self.existing_version_id = existing_version_id | |
| super().__init__(f"A baseline already exists (version {existing_version_id})") | |
| class NotFoundError(DomainError): | |
| def __init__(self, what: str): | |
| self.what = what | |
| super().__init__(f"{what} not found") | |
| class MissingDurationError(DomainError): | |
| """A WORKING activity lacks effort_days, or a WALL activity lacks lead_time_days.""" | |
| def __init__(self, activity_id: int, clock: str): | |
| self.activity_id = activity_id | |
| self.clock = clock | |
| field = "effort_days" if clock == "WORKING" else "lead_time_days" | |
| super().__init__( | |
| f"Activity {activity_id} ({clock}) is missing {field}; cannot schedule it." | |
| ) | |