From baf3d4cd12ac1dda157507f648ae1fb4fa95b58c Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sun, 18 Dec 2022 23:58:09 -0500 Subject: err handling --- resources/outbox.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'resources/outbox.go') diff --git a/resources/outbox.go b/resources/outbox.go index 4ac4c6c..ed87dd8 100644 --- a/resources/outbox.go +++ b/resources/outbox.go @@ -32,7 +32,7 @@ func RenderOutboxPage(name, domain string, db *badger.DB) (map[string]interface{ itemsProp := streams.NewActivityStreamsOrderedItemsProperty() - db.View(func(txn *badger.Txn) error { + err = db.View(func(txn *badger.Txn) error { it := txn.NewIterator(badger.DefaultIteratorOptions) defer it.Close() prefix := []byte("outbox:sample") // TODO @@ -58,6 +58,9 @@ func RenderOutboxPage(name, domain string, db *badger.DB) (map[string]interface{ } return nil }) + if err != nil { + return nil, err + } oc.SetActivityStreamsOrderedItems(itemsProp) return streams.Serialize(oc) @@ -82,15 +85,18 @@ func RenderOutbox(name, domain string, db *badger.DB) (map[string]interface{}, e oc.SetJSONLDId(idProp) var i int - db.View(func(txn *badger.Txn) error { + err = db.View(func(txn *badger.Txn) error { it := txn.NewIterator(badger.DefaultIteratorOptions) defer it.Close() - prefix := []byte("outbox:sample") + prefix := []byte("outbox:sample") // TODO for it.Seek(prefix); it.ValidForPrefix(prefix); it.Next() { i++ } return nil }) + if err != nil { + return nil, err + } itemsProp := streams.NewActivityStreamsTotalItemsProperty() itemsProp.Set(i) -- cgit v1.2.3