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