aboutsummaryrefslogtreecommitdiffstats
path: root/error.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2019-04-04 23:45:56 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2019-04-04 23:45:56 +0200
commit89ea6ebd3671e6ebbf6101525a5416427806f318 (patch)
tree5db52146365a9c2c439b77485f938cc8c2e3a727 /error.go
parentee147062c3bebed83e34bf5ce71019c95f62b96f (diff)
Fixed package tree and go mod filev0.5.0
Change-Id: I1047094d5b80d0622e2c2ce674979f18207b8c0f Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
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,
+ })
+}