mirascope.integrations.tenacity | Mirascope
MirascopeLilypad

mirascope.integrations.tenacity

collect_errors

Alias collect_errors

Collects specified errors into an errors keyword argument.

Example:

from mirascope.integrations.tenacity import collect_errors
from tenacity import retry, stop_after_attempt

@retry(stop=stop_after_attempt(3), after=collect_errors(ValueError))
def throw_value_error(*, errors: list[ValueError] | None = None):
    if errors:
        print(errors[-1])
    raise ValueError("Throwing Error")


try:
    throw_value_error()
    # > Throwing Error
    # > Throwing Error
except RetryError:
    ...

Parameters

NameTypeDescription
*args= ()type[Exception]The `Exception` types to catch.

Returns

TypeDescription
(RetryCallState) => None-

Alias to: mirascope.retries.tenacity.collect_errors