fix: Improve relay error logging

- Log errors with the channel ID and the error message.
- Also log errors with the channel ID and a JSON representation of the error.
This commit is contained in:
Laisky.Cai 2024-02-22 03:17:19 +00:00
parent b9972e0aa4
commit d22c22d4f0

View File

@ -50,7 +50,7 @@ func Relay(c *gin.Context) {
}) })
} }
channelId := c.GetInt("channel_id") channelId := c.GetInt("channel_id")
logger.Error(c.Request.Context(), fmt.Sprintf("relay error (channel #%d): %s", channelId, err.Message)) logger.Error(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 util.ShouldDisableChannel(&err.Error, err.StatusCode) { if util.ShouldDisableChannel(&err.Error, err.StatusCode) {
channelId := c.GetInt("channel_id") channelId := c.GetInt("channel_id")