aboutsummaryrefslogtreecommitdiffstats
path: root/golib/error.go
blob: 6873d8231330b8e16410403f203e77212ba6c576 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package common

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

// APIError returns an uniform json formatted error
func APIError(c *gin.Context, format string, args ...interface{}) {
	errMsg := fmt.Sprintf(format, args...)
	c.JSON(500, gin.H{
		"status": "error",
		"error":  errMsg,
	})
}