Wrap LN importer into try/catch

This commit is contained in:
nymkappa 2022-08-18 07:48:58 +02:00
parent 50d99634f7
commit c37b4cadb1
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -262,6 +262,7 @@ class LightningStatsImporter {
* Import topology files LN historical data into the database * Import topology files LN historical data into the database
*/ */
async $importHistoricalLightningStats(): Promise<void> { async $importHistoricalLightningStats(): Promise<void> {
try {
const fileList = await fsPromises.readdir(this.topologiesFolder); const fileList = await fsPromises.readdir(this.topologiesFolder);
// Insert history from the most recent to the oldest // Insert history from the most recent to the oldest
// This also put the .json cached files first // This also put the .json cached files first
@ -339,6 +340,9 @@ class LightningStatsImporter {
if (totalProcessed > 0) { if (totalProcessed > 0) {
logger.info(`Lightning network stats historical import completed`); logger.info(`Lightning network stats historical import completed`);
} }
} catch (e) {
logger.err(`Lightning network stats historical failed. Reason: ${e instanceof Error ? e.message : e}`);
}
} }
} }