Source code for ppc_robot_lib.utils.errors
[docs]
def get_cause(exc: BaseException) -> BaseException:
"""
Gets exception that caused the given exception (stored in ``__cause__``). If the caused is not set for the input
exception, the exception itself will be returned.
:param exc: Input exception.
:return: Exception that caused the exception.
"""
if hasattr(exc, '__cause__') and exc.__cause__:
return exc.__cause__
else:
return exc