-
Notifications
You must be signed in to change notification settings - Fork 357
Description
Is your feature request related to a problem? Please describe.
Server-side exceptions (ServerError) implement __repr__ for developer-friendly debugging output, but client-side exceptions (A2AClientHTTPError, A2AClientJSONError, A2AClientTimeoutError, A2AClientInvalidArgsError, A2AClientInvalidStateError, A2AClientJSONRPCError) do not. When these exceptions appear during debugging, they show minimal information:
>>> repr(A2AClientHTTPError(404, 'Not Found'))
"A2AClientHTTPError('HTTP Error 404: Not Found')" # Only str() info via Exception defaultFor JSON-RPC errors, the situation is worse — repr flattens the underlying error object into a single string, losing structured access to error code and data during inspection.
Describe the solution you'd like
Add __repr__ methods to all client exception classes in src/a2a/client/errors.py, following the same pattern already established by ServerError.__repr__ in src/a2a/utils/errors.py:
# A2AClientHTTPError
def __repr__(self) -> str:
return (
f'{self.__class__.__name__}('
f'status_code={self.status_code!r}, '
f'message={self.message!r})'
)
# A2AClientJSONError, A2AClientTimeoutError, etc.
def __repr__(self) -> str:
return f'{self.__class__.__name__}(message={self.message!r})'
# A2AClientJSONRPCError
def __repr__(self) -> str:
return f'{self.__class__.__name__}({self.error!r})'This change does not alter traceback formatting or __str__ output; it is intended to improve debuggability via repr() in REPLs, logs, and structured logging contexts.
Describe alternatives you've considered
Relying on the default Exception.__repr__, which only shows str() output and loses structured attributes like status_code.
Additional context
This is a purely additive change and does not affect exception hierarchy, catching behavior, or existing error handling logic.
Code of Conduct
- I agree to follow this project's Code of Conduct