refactor: Enhance error handling and logging in relay controller

- Update error logging in relay controller
- Include error summary and request details in error log message
- Improve formatting for more descriptive and comprehensive error log messages
This commit is contained in:
Laisky.Cai 2023-12-18 02:44:26 +00:00
parent a889d9dcc9
commit 287376dd97

View File

@ -384,7 +384,7 @@ func Relay(c *gin.Context) {
}) })
} }
channelId := c.GetInt("channel_id") channelId := c.GetInt("channel_id")
common.LogError(c.Request.Context(), fmt.Sprintf("relay error (channel #%d): %s", channelId, err.Message)) common.LogError(c.Request.Context(), fmt.Sprintf("relay error (channel #%d): %+v", channelId, err))
// https://platform.openai.com/docs/guides/error-codes/api-errors // https://platform.openai.com/docs/guides/error-codes/api-errors
if shouldDisableChannel(&err.OpenAIError, err.StatusCode) { if shouldDisableChannel(&err.OpenAIError, err.StatusCode) {
channelId := c.GetInt("channel_id") channelId := c.GetInt("channel_id")