From f0c7a95f774eefa981a5e67785813f62fb78f9a9 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Thu, 13 Jul 2023 14:31:08 +0800 Subject: [PATCH] ignore 400 --- main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 0d32e4e..27d8884 100644 --- a/main.go +++ b/main.go @@ -187,11 +187,6 @@ func main() { // abort to error handle c.AbortWithError(502, err) - // count failed - if err.Error() != "context canceled" { - go db.Model(&upstream).Update("failed_count", gorm.Expr("failed_count + ?", 1)) - } - // send notification upstreams := []OPENAI_UPSTREAM{} db.Find(&upstreams) @@ -207,7 +202,9 @@ func main() { strings.Join(upstreamDescriptions, "\n"), ) go sendMatrixMessage(content) - if err.Error() != "context canceled" { + if err.Error() != "context canceled" && r.Response.StatusCode != 400 { + // count failed + go db.Model(&upstream).Update("failed_count", gorm.Expr("failed_count + ?", 1)) go sendFeishuMessage(content) }