Skip to content

pydantic_graph.exceptions

GraphSetupError

Bases: TypeError

Error caused by an incorrectly configured graph.

Source code in pydantic_graph/pydantic_graph/exceptions.py
 7
 8
 9
10
11
12
13
14
15
class GraphSetupError(TypeError):
    """Error caused by an incorrectly configured graph."""

    message: str
    """Description of the mistake."""

    def __init__(self, message: str):
        self.message = message
        super().__init__(message)

message instance-attribute

message: str = message

Description of the mistake.

GraphRuntimeError

Bases: RuntimeError

Error caused by an issue during graph execution.

Source code in pydantic_graph/pydantic_graph/exceptions.py
18
19
20
21
22
23
24
25
26
class GraphRuntimeError(RuntimeError):
    """Error caused by an issue during graph execution."""

    message: str
    """The error message."""

    def __init__(self, message: str):
        self.message = message
        super().__init__(message)

message instance-attribute

message: str = message

The error message.

GraphNodeStatusError

Bases: GraphRuntimeError

Error caused by trying to run a node that already has status 'running', 'success', or 'error'.

Source code in pydantic_graph/pydantic_graph/exceptions.py
29
30
31
32
33
34
35
36
37
38
39
40
class GraphNodeStatusError(GraphRuntimeError):
    """Error caused by trying to run a node that already has status `'running'`, `'success'`, or `'error'`."""

    def __init__(self, actual_status: 'SnapshotStatus'):
        self.actual_status = actual_status
        super().__init__(f"Incorrect snapshot status {actual_status!r}, must be 'created' or 'pending'.")

    @classmethod
    def check(cls, status: 'SnapshotStatus') -> None:
        """Check if the status is valid."""
        if status not in {'created', 'pending'}:
            raise cls(status)

check classmethod

check(status: SnapshotStatus) -> None

Check if the status is valid.

Source code in pydantic_graph/pydantic_graph/exceptions.py
36
37
38
39
40
@classmethod
def check(cls, status: 'SnapshotStatus') -> None:
    """Check if the status is valid."""
    if status not in {'created', 'pending'}:
        raise cls(status)