Skip to content

pubsub_decorators

frog.hardware.pubsub_decorators ¤

Provides a decorator for catching and forwarding errors via pubsub.

Functions¤

pubsub_errors(error_topic) ¤

Catch exceptions and broadcast via pubsub.

Parameters:

Name Type Description Default
error_topic str

The topic name on which to broadcast errors

required
Source code in src/frog/hardware/pubsub_decorators.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def pubsub_errors(error_topic: str) -> Callable:
    """Catch exceptions and broadcast via pubsub.

    Args:
        error_topic: The topic name on which to broadcast errors
    """

    def wrapped(func: Callable, *args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as error:
            _error_occurred(error_topic, error)

    return decorator(wrapped)