mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-17 16:06:38 +08:00
28 lines
666 B
Go
28 lines
666 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"one-api/common"
|
|
)
|
|
|
|
func abortWithOpenAiMessage(c *gin.Context, statusCode int, message string) {
|
|
c.JSON(statusCode, gin.H{
|
|
"error": gin.H{
|
|
"message": common.MessageWithRequestId(message, c.GetString(common.RequestIdKey)),
|
|
"type": "new_api_error",
|
|
},
|
|
})
|
|
c.Abort()
|
|
common.LogError(c.Request.Context(), message)
|
|
}
|
|
|
|
func abortWithMidjourneyMessage(c *gin.Context, statusCode int, code int, description string) {
|
|
c.JSON(statusCode, gin.H{
|
|
"description": description,
|
|
"type": "new_api_error",
|
|
"code": code,
|
|
})
|
|
c.Abort()
|
|
common.LogError(c.Request.Context(), description)
|
|
}
|