Commit 3243f229 by CaIon

feat: add upstream error type and default handling for OpenAI and Claude errors

parent 0e2ec053
......@@ -28,6 +28,7 @@ const (
ErrorTypeMidjourneyError ErrorType = "midjourney_error"
ErrorTypeGeminiError ErrorType = "gemini_error"
ErrorTypeRerankError ErrorType = "rerank_error"
ErrorTypeUpstreamError ErrorType = "upstream_error"
)
type ErrorCode string
......@@ -194,6 +195,9 @@ func WithOpenAIError(openAIError OpenAIError, statusCode int) *NewAPIError {
if !ok {
code = fmt.Sprintf("%v", openAIError.Code)
}
if openAIError.Type == "" {
openAIError.Type = "upstream_error"
}
return &NewAPIError{
RelayError: openAIError,
errorType: ErrorTypeOpenAIError,
......@@ -204,6 +208,9 @@ func WithOpenAIError(openAIError OpenAIError, statusCode int) *NewAPIError {
}
func WithClaudeError(claudeError ClaudeError, statusCode int) *NewAPIError {
if claudeError.Type == "" {
claudeError.Type = "upstream_error"
}
return &NewAPIError{
RelayError: claudeError,
errorType: ErrorTypeClaudeError,
......
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