-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIError
is suggested to be returned from stream.Recv()
#302
Labels
enhancement
New feature or request
Comments
never mind, I found a way to to that func getErrType(err error) string {
unwrappedError := errors.Unwrap(err)
if unwrappedError != nil {
if apiErr, ok := unwrappedError.(*openai.APIError); ok {
return apiErr.Type
}
}
return ""
} |
This can be solved by using
|
I'm closing this because it appears to have already been resolved. |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the example below, it is very helpful to get
err type
other than err message at some cases. For example, when your quota exceeded, the raw response isThis error will be returned by
stream.Recv()
and the error message is generated aserror, You exceeded your current quota, please check your plan and billing details."
. Error message is changeable due to many reasons, thus it is imprecise to determine that the account has no quota through it. Instead,error type
is needed here since it is supposed to be hard to change.So, an error object to return is needed here, a.k.a,
APIError
is suggested to be returned fromstream.Recv()
The text was updated successfully, but these errors were encountered: