patchman/server/utils/handleError.go

15 lines
245 B
Go
Raw Permalink Normal View History

2023-10-26 18:31:57 +02:00
package utils
import (
"github.com/gin-gonic/gin"
"log"
)
func HandleError(err error, status int, message string, c *gin.Context) {
if err != nil {
c.JSON(status, gin.H{"error": err})
log.Printf("%s: %v", message, err)
c.Abort()
}
}