Skip to content

Commit

Permalink
Added try catch to avoid displaying error when there are no comments …
Browse files Browse the repository at this point in the history
…to preload, the error could be ignored but it might confuse some people so best to hide it
  • Loading branch information
tuxfoo committed May 16, 2021
1 parent 86d5cdf commit 003ac7c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,14 @@ module.exports = function (nodecg) {
json: true,
body: myJSONObject
}, function (error, response, body){
nodecg.log.info("Preloaded Comment");
nodecg.log.info("Preloading Comment");
(async function() {
for (var i = 0, j = body.result.items.length - 1; i < body.result.items.length - 1; i++, j--) {
await addComment(body.result.items[j]);
try {
for (var i = 0, j = body.result.items.length - 1; i < body.result.items.length - 1; i++, j--) {
await addComment(body.result.items[j]);
}
} catch {
nodecg.log.info("There does not appear to be any prevoius comments to load. Skipping...");
}
})();
});
Expand Down

0 comments on commit 003ac7c

Please sign in to comment.