aboutsummaryrefslogtreecommitdiffstats
path: root/golib/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'golib/error.go')
-rw-r--r--golib/error.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/golib/error.go b/golib/error.go
new file mode 100644
index 0000000..6873d82
--- /dev/null
+++ b/golib/error.go
@@ -0,0 +1,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,
+ })
+}