Sobes.tech
Junior — Senior

Decorator for exception handling with callback invocation

livecode

Task condition

It is necessary to implement a decorator that takes a list of tuples as a parameter — a correspondence between an exception and a handler function. When the specified exception occurs within the decorated function, the decorator should call the associated callback.

def handler(pairs: list[tuple[Exception, Callable[[], None]]]):
    ...