跳到内容

pydantic_graph.exceptions

GraphSetupError

基类:TypeError

由配置不正确的图引起的错误。

源代码位于 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)

消息 instance-attribute

message: str = message

错误的描述。

GraphRuntimeError

基类:RuntimeError

由图执行期间的问题引起的错误。

源代码位于 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)

消息 instance-attribute

message: str = message

错误消息。

GraphNodeStatusError

基类:GraphRuntimeError

尝试运行已具有 'running', 'success', 或 'error' 状态的节点时引起的错误。

源代码位于 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)

检查 classmethod

check(status: SnapshotStatus) -> None

检查状态是否有效。

源代码位于 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)