fix error response code

This commit is contained in:
2023-11-01 17:53:57 +08:00
parent a3fff93f2e
commit 3c4c2b5660

View File

@@ -76,6 +76,9 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s
if !haveResponse {
log.Println("Timeout upstream", upstream.Endpoint)
errCtx = errors.New("timeout")
if shouldResponse {
c.AbortWithError(502, errCtx)
}
cancel()
}
}()
@@ -130,8 +133,6 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s
haveResponse = true
log.Println("Error", err, upstream.SK, upstream.Endpoint)
log.Println("debug", r)
errCtx = err
// abort to error handle