Improve error messages for Rust client and Try with variant#3768
Improve error messages for Rust client and Try with variant#3768virajmehta merged 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves error messages for the Rust client by standardizing error field naming and enhancing error message formatting. The changes focus on renaming the text field to message in the TensorZeroError::Http variant and implementing JSON error parsing for better error handling.
- Renamed
textfield tomessageinTensorZeroError::Httpvariant for consistency - Enhanced error message formatting with conditional display logic
- Added JSON error parsing to extract structured error messages from API responses
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| clients/rust/src/lib.rs | Updated error struct field name, improved error message formatting, and added JSON error parsing |
| clients/python/src/lib.rs | Updated field reference from text to message in error conversion |
| tensorzero-core/tests/e2e/rate_limiting.rs | Updated test assertions to use message field instead of text |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Fix #3519
Important
Improved error message handling for Python and Rust clients by simplifying Python test assertions and enhancing Rust error parsing logic.
test_client.pyby removing JSON formatting from expected error messages.TensorZeroError::Httpinlib.rsto attempt JSON parsing of error messages before using raw text.check_http_response()andhttp_inference_stream()to extracterrorfrom JSON response if available, otherwise use raw body.try_adjust_tool_call_arguments()to handle tool call arguments based on gateway version.This description was created by
for 37cbe7f. You can customize this summary. It will automatically update as commits are pushed.