From cf7d11daaed36250eace3da475817eaeb835e728 Mon Sep 17 00:00:00 2001 From: Nikita Tokarchuk Date: Thu, 21 Feb 2019 15:37:25 +0100 Subject: [PATCH] Fix error handling in LoadArray --- mongox/common/loadarray.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mongox/common/loadarray.go b/mongox/common/loadarray.go index 5505464..5a9f47f 100644 --- a/mongox/common/loadarray.go +++ b/mongox/common/loadarray.go @@ -51,13 +51,13 @@ func LoadArray(db *mongox.Database, target interface{}, filters ...interface{}) for i = 0; result.Next(db.Context()); { if targetSliceV.Len() == i { elem := reflect.New(targetSliceElemT.Elem()) - if result.Decode(elem.Interface()) != nil { + if err = result.Decode(elem.Interface()); err == nil { targetSliceV = reflect.Append(targetSliceV, elem) } else { continue } - } else { - result.Decode(targetSliceV.Index(i).Interface()) + } else if err = result.Decode(targetSliceV.Index(i).Interface()); err != nil { + continue } i++