Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
ff8f128fe8
|
|||
1971f1396f
|
@@ -169,14 +169,32 @@ func (ee *ExErr) ShortLog(evt *zerolog.Event) {
|
|||||||
|
|
||||||
// RecursiveMessage returns the message to show
|
// RecursiveMessage returns the message to show
|
||||||
// = first error (top-down) that is not wrapping/foreign/empty
|
// = first error (top-down) that is not wrapping/foreign/empty
|
||||||
|
// = lowest level error (that is not empty)
|
||||||
|
// = fallback to self.message
|
||||||
func (ee *ExErr) RecursiveMessage() string {
|
func (ee *ExErr) RecursiveMessage() string {
|
||||||
|
|
||||||
|
// ==== [1] ==== first error (top-down) that is not wrapping/foreign/empty
|
||||||
|
|
||||||
for curr := ee; curr != nil; curr = curr.OriginalError {
|
for curr := ee; curr != nil; curr = curr.OriginalError {
|
||||||
if curr.Message != "" && curr.Category != CatWrap && curr.Category != CatForeign {
|
if curr.Message != "" && curr.Category != CatWrap && curr.Category != CatForeign {
|
||||||
return curr.Message
|
return curr.Message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback to self
|
// ==== [2] ==== lowest level error (that is not empty)
|
||||||
|
|
||||||
|
deepestMsg := ""
|
||||||
|
for curr := ee; curr != nil; curr = curr.OriginalError {
|
||||||
|
if curr.Message != "" {
|
||||||
|
deepestMsg = curr.Message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if deepestMsg != "" {
|
||||||
|
return deepestMsg
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==== [3] ==== fallback to self.message
|
||||||
|
|
||||||
return ee.Message
|
return ee.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.310"
|
const GoextVersion = "0.0.312"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2023-11-09T11:40:48+0100"
|
const GoextVersionTimestamp = "2023-11-10T10:16:31+0100"
|
||||||
|
@@ -2,8 +2,6 @@ package wmo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
|
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
|
||||||
@@ -42,17 +40,11 @@ func (c *Coll[TData]) Paginate(ctx context.Context, filter pag.Filter, page int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pipelineCount := mongo.Pipeline{}
|
pipelineCount := mongo.Pipeline{}
|
||||||
pipelinePaginate = append(pipelinePaginate, bson.D{{Key: "$count", Value: "count"}})
|
pipelineCount = append(pipelineCount, bson.D{{Key: "$count", Value: "count"}})
|
||||||
|
|
||||||
pipelineList := langext.ArrConcat(mongo.Pipeline{}, pipelineFilter, pipelinePaginate, c.extraModPipeline)
|
pipelineList := langext.ArrConcat(mongo.Pipeline{}, pipelineFilter, pipelinePaginate, c.extraModPipeline)
|
||||||
pipelineTotalCount := langext.ArrConcat(mongo.Pipeline{}, pipelineFilter, pipelineCount)
|
pipelineTotalCount := langext.ArrConcat(mongo.Pipeline{}, pipelineFilter, pipelineCount)
|
||||||
|
|
||||||
vv1, err := json.MarshalIndent(pipelineList, "", " ")
|
|
||||||
fmt.Printf("\n==============================\n%s\n==============================\n\n", string(vv1))
|
|
||||||
|
|
||||||
vv2, err := json.MarshalIndent(pipelineTotalCount, "", " ")
|
|
||||||
fmt.Printf("\n==============================\n%s\n==============================\n\n", string(vv2))
|
|
||||||
|
|
||||||
cursorList, err := c.coll.Aggregate(ctx, pipelineList)
|
cursorList, err := c.coll.Aggregate(ctx, pipelineList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, pag.Pagination{}, exerr.Wrap(err, "mongo-aggregation failed").Any("pipeline", pipelineList).Str("collection", c.Name()).Build()
|
return nil, pag.Pagination{}, exerr.Wrap(err, "mongo-aggregation failed").Any("pipeline", pipelineList).Str("collection", c.Name()).Build()
|
||||||
|
Reference in New Issue
Block a user