File size: 1,020 Bytes
9c50399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45ca73e
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""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."
        )