Skip to content

Commit 3bcd1da

Browse files
authored
Merge branch 'main' into push-notifications
2 parents 4a596b5 + 2c152c0 commit 3bcd1da

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/a2a/utils/errors.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ def __init__(
6666
6767
Args:
6868
error: The specific A2A or JSON-RPC error model instance.
69-
If None, an `InternalError` will be used when formatting the response.
7069
"""
7170
self.error = error
71+
72+
def __str__(self) -> str:
73+
"""Returns a readable representation of the internal Pydantic error."""
74+
if self.error is None:
75+
return 'None'
76+
if self.error.message is None:
77+
return self.error.__class__.__name__
78+
return self.error.message
79+
80+
def __repr__(self) -> str:
81+
"""Returns an unambiguous representation for developers showing how the ServerError was constructed with the internal Pydantic error."""
82+
return f'{self.__class__.__name__}({self.error!r})'

0 commit comments

Comments
 (0)