patchman/server/utils/handleError.go

15 lines
245 B
Go
Raw Normal View History

2023-10-26 16:31:57 +00: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()
}
}