Junior — Middle+
Creating a decorator with automatic retry on error
livecode
Task condition
It is required to write a decorator that will perform retries when calling a function if it throws an exception. An error is considered any thrown Exception. Example of usage:
@retry(...)
def func(data: str) -> str:
if random.random() > 0.5:
raise ValueError(data)
return data
The decorator should accept parameters that allow setting the number of attempts and the types of exceptions to catch.