fix: fix aws claude panic (#1384)

This commit is contained in:
JustSong 2024-04-29 22:49:06 +08:00
parent 7e027d2bd0
commit 1f76c80553
2 changed files with 13 additions and 0 deletions

View File

@ -53,6 +53,16 @@ func (e GeneralErrorResponse) ToMessage() string {
} }
func RelayErrorHandler(resp *http.Response) (ErrorWithStatusCode *model.ErrorWithStatusCode) { func RelayErrorHandler(resp *http.Response) (ErrorWithStatusCode *model.ErrorWithStatusCode) {
if resp == nil {
return &model.ErrorWithStatusCode{
StatusCode: 500,
Error: model.Error{
Message: "resp is nil",
Type: "upstream_error",
Code: "bad_response",
},
}
}
ErrorWithStatusCode = &model.ErrorWithStatusCode{ ErrorWithStatusCode = &model.ErrorWithStatusCode{
StatusCode: resp.StatusCode, StatusCode: resp.StatusCode,
Error: model.Error{ Error: model.Error{

View File

@ -208,6 +208,9 @@ func getMappedModelName(modelName string, mapping map[string]string) (string, bo
func isErrorHappened(meta *meta.Meta, resp *http.Response) bool { func isErrorHappened(meta *meta.Meta, resp *http.Response) bool {
if resp == nil { if resp == nil {
if meta.ChannelType == channeltype.AwsClaude {
return false
}
return true return true
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {