From ae7e297622ed081fa3f04838c04ede7ad9ef3aaa Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 4 Mar 2026 12:40:06 +0100 Subject: [PATCH] loadone catch error --- models/utils/common.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/models/utils/common.go b/models/utils/common.go index 118fe89..fe68aae 100755 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -133,7 +133,10 @@ func GenericLoadOne[T DBObject](id string, data T, f func(DBObject) (DBObject, i return nil, code, err } fmt.Println("APPLY", data, res_mongo) - res_mongo.Decode(&data) + if err = res_mongo.Decode(&data); err == nil { + return nil, 400, err + } + if a.ShouldVerifyAuth() && !data.VerifyAuth("get", a.GetRequest()) { return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String()) }