Don't truncate plugin installation errors
parent
3f3de28091
commit
4a548dc261
|
@ -0,0 +1,5 @@
|
||||||
|
class PluginInstallationError extends Error {}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
PluginInstallationError,
|
||||||
|
};
|
|
@ -17,6 +17,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { BotError } = require("./BotError");
|
const { BotError } = require("./BotError");
|
||||||
|
const { PluginInstallationError } = require("./PluginInstallationError");
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
// Force crash on unhandled rejections and uncaught exceptions.
|
// Force crash on unhandled rejections and uncaught exceptions.
|
||||||
|
@ -46,6 +47,9 @@ function errorHandler(err) {
|
||||||
fullMessage += "4. Turn on 'Server Members Intent'"
|
fullMessage += "4. Turn on 'Server Members Intent'"
|
||||||
|
|
||||||
console.error(fullMessage);
|
console.error(fullMessage);
|
||||||
|
} else if (err instanceof PluginInstallationError) {
|
||||||
|
// Don't truncate PluginInstallationErrors as they can get lengthy
|
||||||
|
console.error(err);
|
||||||
} else {
|
} else {
|
||||||
// Truncate long stack traces for other errors
|
// Truncate long stack traces for other errors
|
||||||
const stack = err.stack || "";
|
const stack = err.stack || "";
|
||||||
|
|
|
@ -9,6 +9,7 @@ const pacote = require("pacote");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const threads = require("./data/threads");
|
const threads = require("./data/threads");
|
||||||
const displayRoles = require("./data/displayRoles");
|
const displayRoles = require("./data/displayRoles");
|
||||||
|
const { PluginInstallationError } = require("./PluginInstallationError");
|
||||||
|
|
||||||
const pluginSources = {
|
const pluginSources = {
|
||||||
npm: {
|
npm: {
|
||||||
|
@ -40,7 +41,7 @@ const pluginSources = {
|
||||||
npmProcess.stderr.on("data", data => { stderr += String(data) });
|
npmProcess.stderr.on("data", data => { stderr += String(data) });
|
||||||
npmProcess.on("close", code => {
|
npmProcess.on("close", code => {
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
return reject(new Error(stderr));
|
return reject(new PluginInstallationError(stderr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolve();
|
return resolve();
|
||||||
|
@ -53,7 +54,7 @@ const pluginSources = {
|
||||||
const packageName = manifest.name;
|
const packageName = manifest.name;
|
||||||
const pluginFn = require(packageName);
|
const pluginFn = require(packageName);
|
||||||
if (typeof pluginFn !== "function") {
|
if (typeof pluginFn !== "function") {
|
||||||
throw new Error(`Plugin '${plugin}' is not a valid plugin`);
|
throw new PluginInstallationError(`Plugin '${plugin}' is not a valid plugin`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginFn(pluginApi);
|
return pluginFn(pluginApi);
|
||||||
|
@ -66,7 +67,7 @@ const pluginSources = {
|
||||||
const requirePath = path.join(__dirname, "..", plugin);
|
const requirePath = path.join(__dirname, "..", plugin);
|
||||||
const pluginFn = require(requirePath);
|
const pluginFn = require(requirePath);
|
||||||
if (typeof pluginFn !== "function") {
|
if (typeof pluginFn !== "function") {
|
||||||
throw new Error(`Plugin '${plugin}' is not a valid plugin`);
|
throw new PluginInstallationError(`Plugin '${plugin}' is not a valid plugin`);
|
||||||
}
|
}
|
||||||
return pluginFn(pluginApi);
|
return pluginFn(pluginApi);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue