Skip to content

Commit

Permalink
fix(autofix): Correctly format chained exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jennmueng committed Jul 16, 2024
1 parent 662071a commit efb41a6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/seer/automation/agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
logger = logging.getLogger(__name__)


def get_full_exception_string(exc):
result = str(exc)
if exc.__cause__:
if result:
result += f"\n\nThe above exception was the direct cause of the following exception:\n\n{str(exc.__cause__)}"
else:
result = str(exc.__cause__)
return result


class FunctionTool(BaseModel):
name: str
description: str
Expand All @@ -18,7 +28,7 @@ def call(self, **kwargs):
return self.fn(**kwargs)
except Exception as e:
logger.exception(e)
return f"Error: {e}"
return f"Error: {get_full_exception_string(e)}"

def to_dict(self):
return {
Expand Down

0 comments on commit efb41a6

Please sign in to comment.