From 5f9074e08662d2cb95b123920dac5f83205159bb Mon Sep 17 00:00:00 2001 From: velvettear Date: Thu, 10 Mar 2022 00:36:59 +0100 Subject: [PATCH] catch errors while filling the cache --- libs/cache.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libs/cache.js b/libs/cache.js index 3357fd0..8e8a609 100644 --- a/libs/cache.js +++ b/libs/cache.js @@ -25,15 +25,20 @@ async function fill() { const timestamp = new Date(); logger.debug('filling cache...'); clear(); - if (modep === undefined) { - modep = require('./modep.js'); + try { + + if (modep === undefined) { + modep = require('./modep.js'); + } + await modep.getBanks(); + await modep.getPedalboards(); + await modep.getDefaultPedalboard(); + await modep.getCurrentPedalboard(); + await modep.getCurrentPedals(); + logger.debug('cache filled after ' + timeDiff(timestamp) + 'ms'); + } catch (err) { + logger.error('encountered an error while filling the cache after ' + timeDiff(timestamp) + 'ms'); } - await modep.getBanks(); - await modep.getPedalboards(); - await modep.getDefaultPedalboard(); - await modep.getCurrentPedalboard(); - await modep.getCurrentPedals(); - logger.debug('cache filled after ' + timeDiff(timestamp) + 'ms'); } function clear() {