Skip to content

Commit ceb985a

Browse files
More error info (#49)
1 parent 9bd4981 commit ceb985a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

api/lists.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package api
55
// See LICENSE file for license details
66

77
import (
8+
"fmt"
89
"strconv"
910
"time"
1011

@@ -347,13 +348,12 @@ func (c *ListsController) Clone(ctx *app.CloneListsContext) error {
347348
opts...,
348349
)
349350
if err != nil {
350-
return err
351+
return fmt.Errorf("failed to create new list: %w", err)
351352
}
352353

353354
// Add to manager
354355
db.Lists.Add(list)
355356

356357
// ListsController_Create: end_implement
357358
return ctx.OKFull(morph.List{In: list}.Full(ctx, db.Storage, true))
358-
359359
}

list.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ func (l ListOption) Cache(cache Cache) ListOption {
147147
// Use WithListOption to access additional options.
148148
func NewList(ctx context.Context, id ListID, set string, bs blobstore.Store, opts ...ListOption) (*List, error) {
149149
ctx = log.WithFn(ctx, "list_id", id)
150+
log.Info(ctx, "Creating new list", "set", set, "list_id", id)
150151
options := defaultListOptions()
151152
for _, opt := range opts {
152153
err := opt(&options)
153154
if err != nil {
154-
return nil, err
155+
return nil, fmt.Errorf("applying option: %v", err)
155156
}
156157
}
157158
if set == "" {
@@ -174,13 +175,13 @@ func NewList(ctx context.Context, id ListID, set string, bs blobstore.Store, opt
174175
e.UpdateTime(time.Now())
175176
err := l.Populate(ctx, bs, e)
176177
if err != nil {
177-
return nil, err
178+
return nil, fmt.Errorf("populating list: %v", err)
178179
}
179180
}
180181
if options.clone != nil {
181182
err := l.cloneElements(ctx, bs, options.clone)
182183
if err != nil {
183-
return nil, err
184+
return nil, fmt.Errorf("cloning list: %v", err)
184185
}
185186
}
186187
if l.Scores.Unset() {

list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//nolint
1+
// nolint
22
package rankdb_test
33

44
// Copyright 2019 Vivino. All rights reserved

0 commit comments

Comments
 (0)