mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
23 lines
475 B
Go
23 lines
475 B
Go
package cosy
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/0xJacky/Nginx-UI/internal/logger"
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
"gorm.io/gorm"
|
|
"net/http"
|
|
)
|
|
|
|
func errHandler(c *gin.Context, err error) {
|
|
logger.GetLogger().WithOptions(zap.AddCallerSkip(1)).Errorln(err)
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
c.JSON(http.StatusNotFound, gin.H{
|
|
"message": err.Error(),
|
|
})
|
|
return
|
|
}
|
|
c.JSON(http.StatusInternalServerError, gin.H{
|
|
"message": err.Error(),
|
|
})
|
|
}
|