output stack in errors

This commit is contained in:
2020-11-28 21:00:36 +01:00
parent 641d96c837
commit ca73fdecf2
2 changed files with 34 additions and 109 deletions

View File

@@ -12,6 +12,14 @@ import (
"gopkg.in/mgo.v2/bson"
)
func errorObject(err error) bson.M {
o := bson.M{"error": err.Error()}
if e, ok := err.(*mgocrud.ErrorWithStack); ok {
o["stack"] = e.Stack()
}
return o
}
func modelTypeOf(m interface{}) reflect.Type {
return reflect.TypeOf(
reflect.ValueOf(m).Elem().Interface(),