Files
2026-04-20 19:41:52 +02:00

21 lines
636 B
Go

package utils
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
)
// BindErr log l'erreur de binding et renvoie 400 sans détails internes.
func BindErr(c *gin.Context, err error) {
log.Printf("⚠️ [BIND] %s %s: %v", c.Request.Method, c.Request.URL.Path, err)
c.JSON(http.StatusBadRequest, gin.H{"error": "Données invalides"})
}
// ServerErr log l'erreur interne et renvoie 500 avec un message générique.
func ServerErr(c *gin.Context, msg string, err error) {
log.Printf("❌ [SERVER] %s %s — %s: %v", c.Request.Method, c.Request.URL.Path, msg, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": msg})
}