Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(wallet): log error if an activity paginator fails to load
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Apr 19, 2020
1 parent 09f472c commit 75c928d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/pagination.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { mainLog } from '@zap/utils/log'

/**
* combinePaginators - Combines multiple simple paginators into a single stateful paginator.
*
Expand Down Expand Up @@ -30,7 +32,12 @@ export default function combinePaginators(itemSorter, ...paginators) {
// checks whether particular paginator has more to yield
const hasMore = p => !offsets.has(p) || offsets.get(p)
const depleted = { offset: 0, items: [] }
const next = p => p(pageSize, offsets.get(p) || 0)
const missing = { offset: 1, items: [] }
const next = p =>
p(pageSize, offsets.get(p) || 0).catch(e => {
mainLog.error('Unable to fetch activity items from %s paginator: %o', p.name, e)
return missing
})
return Promise.all(paginators.map(p => (hasMore(p) ? next(p) : depleted)))
}

Expand Down

0 comments on commit 75c928d

Please # to comment.