Spaces:
Running
Running
File size: 597 Bytes
0913c52 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | """
Error handling utilities.
"""
def sprint_chained_exception(e: Exception) -> str:
ret = repr(e)
while e.__cause__:
ret += f"\n <- {repr(e.__cause__)}"
e = e.__cause__
return ret
class AgentError(Exception):
def __init__(self, *args, agent_name: str = None):
super().__init__(*args)
self.agent_name = agent_name
def __repr__(self):
if self.agent_name:
return f"AgentError({self.agent_name}): {self.args}"
return f"AgentError: {self.args}"
def sprint(self):
return sprint_chained_exception(self)
|