Commit 1a5ba750 by CaIon

fix: correct logic for handling nil OpenAI error codes. (close #1609)

parent 87d0d12d
...@@ -234,7 +234,7 @@ func NewErrorWithStatusCode(err error, errorCode ErrorCode, statusCode int, ops ...@@ -234,7 +234,7 @@ func NewErrorWithStatusCode(err error, errorCode ErrorCode, statusCode int, ops
func WithOpenAIError(openAIError OpenAIError, statusCode int, ops ...NewAPIErrorOptions) *NewAPIError { func WithOpenAIError(openAIError OpenAIError, statusCode int, ops ...NewAPIErrorOptions) *NewAPIError {
code, ok := openAIError.Code.(string) code, ok := openAIError.Code.(string)
if !ok { if !ok {
if openAIError.Code == nil { if openAIError.Code != nil {
code = fmt.Sprintf("%v", openAIError.Code) code = fmt.Sprintf("%v", openAIError.Code)
} else { } else {
code = "unknown_error" code = "unknown_error"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment