You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/units/mock/error_helper.py

18 lines
462 B
Python

from __future__ import annotations
import collections.abc as c
def raise_exceptions(exceptions: c.Sequence[BaseException]) -> None:
"""
Raise a chain of exceptions from the given exception list.
Exceptions will be raised starting from the end of the list.
"""
if len(exceptions) > 1:
try:
raise_exceptions(exceptions[1:])
except Exception as ex:
raise exceptions[0] from ex
raise exceptions[0]