Skip to content

academy.exception

BadEntityIdError

BadEntityIdError(uid: EntityId)

Bases: Exception

Entity associated with the identifier is unknown.

Source code in academy/exception.py
def __init__(self, uid: EntityId) -> None:
    super().__init__(f'Unknown identifier {uid}.')

HandleClosedError

HandleClosedError(
    agent_id: AgentId[Any], mailbox_id: EntityId | None
)

Bases: Exception

Agent handle has been closed.

Source code in academy/exception.py
def __init__(
    self,
    agent_id: AgentId[Any],
    mailbox_id: EntityId | None,
) -> None:
    message = (
        f'Handle to {agent_id} bound to {mailbox_id} has been closed.'
        if mailbox_id is not None
        else f'Handle to {agent_id} has been closed.'
    )
    super().__init__(message)

HandleNotBoundError

HandleNotBoundError(aid: AgentId[Any])

Bases: Exception

Handle to agent is in an unbound state.

An unbound handle (typically, an instance of UnboundRemoteHandle) is initialized with a target agent ID and exchange, but does not have an identifier itself. Thus, the handle does not have a mailbox in the exchange to receive response messages.

A handle must be bound to be used, either as a unique client with its own mailbox or as bound to a running agent where it shares a mailbox with that running agent. To create a client bound handle, use handle.bind_as_client().

Any agent behavior that has a handle to another agent as an instance attribute will be automatically bound to the agent when the agent begins running.

Source code in academy/exception.py
def __init__(self, aid: AgentId[Any]) -> None:
    super().__init__(
        f'Handle to {aid} is not bound as a client nor to a running '
        'agent. See the exception docstring for troubleshooting.',
    )

MailboxClosedError

MailboxClosedError(uid: EntityId)

Bases: Exception

Mailbox is closed and cannot send or receive messages.

Source code in academy/exception.py
def __init__(self, uid: EntityId) -> None:
    super().__init__(f'Mailbox for {uid} has been closed.')