15 lines
243 B
Go
15 lines
243 B
Go
|
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()
|
||
|
}
|
||
|
}
|