heros.exceptions

Exceptions raised by HEROS, in particular those transported from a remote HERO.

Attributes

Exceptions

HEROSError

Base class of all HEROS errors.

RemoteHEROError

An exception that was raised inside a remote HERO while serving a request.

RemoteTransportError

The query to a remote HERO failed at transport level (interrupted stream, ...).

Functions

_error_class(→ type)

Build (and cache) an exception class that is both a RemoteHEROError and, where

Module Contents

heros.exceptions.ERROR_MARKER = '__heros_error__'
exception heros.exceptions.HEROSError[source]

Bases: Exception

Base class of all HEROS errors.

exception heros.exceptions.RemoteHEROError(message: str, remote_type: str | None = None, remote_module: str | None = None, remote_traceback: str | None = None, endpoint: str | None = None)[source]

Bases: HEROSError

An exception that was raised inside a remote HERO while serving a request.

Parameters:
  • message – the str of the remote exception.

  • remote_type – class name of the remote exception, if the remote sent one.

  • remote_traceback – formatted traceback from the remote process.

  • endpoint – the endpoint that was queried.

message
remote_type = None
remote_module = None
remote_traceback = None
endpoint = None
classmethod from_exception(exc: BaseException, endpoint: str | None = None)[source]
classmethod from_payload(payload: Any, endpoint: str | None = None)[source]

Rebuild a remote exception from a serialized payload.

All payloads that do not have the correct format (dict with error marker) are wrapped in a bare RemoteHEROError so that old HEROs keep working.

__str__() → str[source]

Return str(self).

serialize() → dict[str, Any][source]

Turn an exception into a payload that exception_from_payload() can rebuild.

exception heros.exceptions.RemoteTransportError[source]

Bases: HEROSError

The query to a remote HERO failed at transport level (interrupted stream, …).

heros.exceptions._error_classes: dict[str, type]
heros.exceptions._mapping_blacklist
heros.exceptions._error_class(remote_type: str | None) → type[source]

Build (and cache) an exception class that is both a RemoteHEROError and, where the remote exception is a builtin, that builtin.

This lets user code keep writing except ValueError: around a remote call while the HEROS-specific information stays available on the exception object.