ansible/test/units/mock/error_helper.py
Matt Davis cbcefc53a3
Clean up TE error handling, wrap sigalrm handler (#85232)
* Clean up TE error handling, wrap sigalrm handler

* Preserve error detail on AnsibleAction and Connection exceptions.
* Remove multiple layers of unreachable or redundant error handling.
* Wrap manual alarm signal/timeout handling into a context manager, add tests.

Co-authored-by: Matt Clay <matt@mystile.com>

* update error message check in test

* update test timeout message assertions

---------

Co-authored-by: Matt Clay <matt@mystile.com>
2025-05-30 10:45:10 -07:00

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]