From b96e5cc042c674839be203504ef4c7738ebdb7e8 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 17 Sep 2019 19:57:21 +0300 Subject: [PATCH] Print error and stacktrace when package fails to load --- src/plugins/packages/index.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plugins/packages/index.js b/src/plugins/packages/index.js index 01d37436..53b16cd0 100644 --- a/src/plugins/packages/index.js +++ b/src/plugins/packages/index.js @@ -65,23 +65,22 @@ function loadPackages() { } packages.forEach((packageName) => { - const errorMsg = `Package ${colors.bold(packageName)} could not be loaded`; let packageInfo; let packageFile; try { - packageInfo = require(path.join( - Helper.getPackageModulePath(packageName), - "package.json" - )); - packageFile = require(Helper.getPackageModulePath(packageName)); - } catch (e) { - log.warn(errorMsg); - return; - } + const packagePath = Helper.getPackageModulePath(packageName); - if (!packageInfo.thelounge) { - log.warn(errorMsg); + packageInfo = require(path.join(packagePath, "package.json")); + + if (!packageInfo.thelounge) { + throw "'thelounge' is not present in package.json"; + } + + packageFile = require(packagePath); + } catch (e) { + log.error(`Package ${colors.bold(packageName)} could not be loaded: ${colors.red(e)}`); + log.debug(e.stack); return; }