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 { PluginInstallationError } = require("./PluginInstallationError");
|
||||
|
||||
// Error handling
|
||||
// Force crash on unhandled rejections and uncaught exceptions.
|
||||
|
@ -46,6 +47,9 @@ function errorHandler(err) {
|
|||
fullMessage += "4. Turn on 'Server Members Intent'"
|
||||
|
||||
console.error(fullMessage);
|
||||
} else if (err instanceof PluginInstallationError) {
|
||||
// Don't truncate PluginInstallationErrors as they can get lengthy
|
||||
console.error(err);
|
||||
} else {
|
||||
// Truncate long stack traces for other errors
|
||||
const stack = err.stack || "";
|
||||
|
|
|
@ -9,6 +9,7 @@ const pacote = require("pacote");
|
|||
const path = require("path");
|
||||
const threads = require("./data/threads");
|
||||
const displayRoles = require("./data/displayRoles");
|
||||
const { PluginInstallationError } = require("./PluginInstallationError");
|
||||
|
||||
const pluginSources = {
|
||||
npm: {
|
||||
|
@ -40,7 +41,7 @@ const pluginSources = {
|
|||
npmProcess.stderr.on("data", data => { stderr += String(data) });
|
||||
npmProcess.on("close", code => {
|
||||
if (code !== 0) {
|
||||
return reject(new Error(stderr));
|
||||
return reject(new PluginInstallationError(stderr));
|
||||
}
|
||||
|
||||
return resolve();
|
||||
|
@ -53,7 +54,7 @@ const pluginSources = {
|
|||
const packageName = manifest.name;
|
||||
const pluginFn = require(packageName);
|
||||
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);
|
||||
|
@ -66,7 +67,7 @@ const pluginSources = {
|
|||
const requirePath = path.join(__dirname, "..", plugin);
|
||||
const pluginFn = require(requirePath);
|
||||
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);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue