patchman/server/api/handleError.go

15 lines
243 B
Go
Raw Normal View History

package api
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()
}
}