print stack on errors
This commit is contained in:
32
handler.go
32
handler.go
@@ -5,6 +5,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"gitbase.de/gopackage/mgocrud"
|
"gitbase.de/gopackage/mgocrud"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
mgo "gopkg.in/mgo.v2"
|
mgo "gopkg.in/mgo.v2"
|
||||||
@@ -25,6 +27,7 @@ func (api *API) collectionGetOneHandler(m mgocrud.ModelInterface) gin.HandlerFun
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": "select: " + err.Error(),
|
"error": "select: " + err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -37,6 +40,7 @@ func (api *API) collectionGetOneHandler(m mgocrud.ModelInterface) gin.HandlerFun
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": "select: " + err.Error(),
|
"error": "select: " + err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -49,6 +53,7 @@ func (api *API) collectionGetOneHandler(m mgocrud.ModelInterface) gin.HandlerFun
|
|||||||
}
|
}
|
||||||
c.JSON(status, gin.H{
|
c.JSON(status, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -61,6 +66,7 @@ func (api *API) collectionGetOneHandler(m mgocrud.ModelInterface) gin.HandlerFun
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -97,6 +103,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": "filter: " + err.Error(),
|
"error": "filter: " + err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -109,6 +116,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": "filter: " + err.Error(),
|
"error": "filter: " + err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -126,6 +134,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": "select: " + err.Error(),
|
"error": "select: " + err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -139,6 +148,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": "select: " + err.Error(),
|
"error": "select: " + err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -162,6 +172,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -180,6 +191,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -189,6 +201,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -201,6 +214,7 @@ func (api *API) collectionGetHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -223,6 +237,7 @@ func (api *API) collectionPostHandler(m mgocrud.ModelInterface) gin.HandlerFunc
|
|||||||
if err := c.Bind(newM); err != nil {
|
if err := c.Bind(newM); err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -238,6 +253,7 @@ func (api *API) collectionPostHandler(m mgocrud.ModelInterface) gin.HandlerFunc
|
|||||||
}, newM, nil); err != nil {
|
}, newM, nil); err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
"apiContext": "validateObject",
|
"apiContext": "validateObject",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -247,6 +263,7 @@ func (api *API) collectionPostHandler(m mgocrud.ModelInterface) gin.HandlerFunc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
"apiContext": "createDocument",
|
"apiContext": "createDocument",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -258,6 +275,7 @@ func (api *API) collectionPostHandler(m mgocrud.ModelInterface) gin.HandlerFunc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
"apiContext": "readDocument",
|
"apiContext": "readDocument",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -270,6 +288,7 @@ func (api *API) collectionPostHandler(m mgocrud.ModelInterface) gin.HandlerFunc
|
|||||||
}, readM, nil); err != nil {
|
}, readM, nil); err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
"apiContext": "savedObject",
|
"apiContext": "savedObject",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -283,6 +302,7 @@ func (api *API) collectionPostHandler(m mgocrud.ModelInterface) gin.HandlerFunc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -305,6 +325,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
c.JSON(status, gin.H{
|
c.JSON(status, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -314,6 +335,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err := c.Bind(newM); err != nil {
|
if err := c.Bind(newM); err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -322,6 +344,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if newM.GetID() != nil {
|
if newM.GetID() != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": "id not allowed in update",
|
"error": "id not allowed in update",
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -336,6 +359,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -344,6 +368,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -394,6 +419,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
}, orgM, changes); err != nil {
|
}, orgM, changes); err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -402,6 +428,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -412,6 +439,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -423,6 +451,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
}, newM, changes); err != nil {
|
}, newM, changes); err != nil {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -435,6 +464,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -459,6 +489,7 @@ func (api *API) collectionDeleteHandler(m mgocrud.ModelInterface) gin.HandlerFun
|
|||||||
}
|
}
|
||||||
c.JSON(status, gin.H{
|
c.JSON(status, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -467,6 +498,7 @@ func (api *API) collectionDeleteHandler(m mgocrud.ModelInterface) gin.HandlerFun
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(500, gin.H{
|
c.JSON(500, gin.H{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
"stack": string(debug.Stack()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user