optimize(openai): enhance APIError struct with InnerError field #752
Open
zbysir wants to merge 3 commits intocloudwego:mainfrom
Open
optimize(openai): enhance APIError struct with InnerError field #752zbysir wants to merge 3 commits intocloudwego:mainfrom
zbysir wants to merge 3 commits intocloudwego:mainfrom
Conversation
…p method - Add InnerError field to APIError for better error context - Implement Unwrap method to facilitate error unwrapping in error handling - Update convOrigAPIError function to populate InnerError with the original error
Author
|
CI reported an error: Need to create a new tag\nThe following modules have changes and may need version updates:\n- components/model/openai (Current: components/model/openai/v0.1.10)\n\n\n Do I need to handle this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance APIError struct with InnerError field.
Motivation
I found that the
convOrigAPIErrormethod leads to the loss of internal error information. Many providers (e.g., OpenRouter) customize their error messages rather than using only Code, Message, and Param. Therefore, preserving the original internal error is necessary.An example:
When using OpenRouter with OpenAI, an error occurs and returns a very brief but useless error message:
[NodeRunError] error, status code: 400, status: 400 Bad Request, message: Provider returned error.Developers cannot retrieve the full underlying error via
unwraporerror.As.Regardless, wrapping an error while preserving the internal error is a better approach.