From 0ad9def514c1d9be6301079781ee6eb1abb47670 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 26 Apr 2018 12:11:38 +0300 Subject: [PATCH] Gracefully fail if sqlite3 module fails to load --- src/plugins/sqlite.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/sqlite.js b/src/plugins/sqlite.js index 2e4d0f87..d3d39e80 100644 --- a/src/plugins/sqlite.js +++ b/src/plugins/sqlite.js @@ -2,10 +2,19 @@ const path = require("path"); const fsextra = require("fs-extra"); -const sqlite3 = require("sqlite3"); const Helper = require("../helper"); const Msg = require("../models/msg"); +let sqlite3; + +try { + sqlite3 = require("sqlite3"); +} catch (e) { + Helper.config.messageStorage = Helper.config.messageStorage.filter((item) => item !== "sqlite"); + + log.error("Unable to load sqlite3 module. You might need to install it manually."); +} + const currentSchemaVersion = 1520239200; const schema = [