Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumewuip committed Aug 30, 2023
1 parent 5d838da commit bc37959
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rss-to-tana/tana.js
Expand Up @@ -35,7 +35,7 @@ function postItems(items) {
})
.then(response => {
if (!response.ok || response.status !== 200) {
throw new Error(`Error saving nodes: ${response.status} ${response.statusText}`)
throw new Error(`Error saving nodes in Tana: ${response.status} ${response.statusText}`)
}
})
}
Expand All @@ -52,13 +52,11 @@ setInterval(
const items = queue.splice(0, Infinity)

postItems(items)
.then(() => Log.info(`${items.length} items saved to Tana`))
.then(() => Store.saveItemsSaved(items.map(item => item.id)))
.then(() => {
Log.info(`${items.length} items saved to Tana`);
})
// in case of failure, we put back items in the queue
.catch(error => {
Log.error(error);
Log.error('Error in saving items', error);
queue.push(...items)
});
}
Expand Down

0 comments on commit bc37959

Please sign in to comment.