Add more context to missing handler error

Amend the error message shown when a message handler is missing from a
plugin with the expected name of the handler and the name of the plugin
it's missing from.
This commit is contained in:
Hornwitser committed 2020-11-12 04:17:52 +01:00
1 parent 5b74432ee3
commit 65a25e2510
3 files changed
+47 -10

No files matched your search

+16 -6
View File
@@ -402,13 +402,23 @@ function attachPluginMessages(link, pluginInfo, plugin) {
}
let handler = name + messageFormat.handlerSuffix;
if (plugin === null || !plugin[handler]) {
messageFormat.attach(link);
try {
if (plugin === null || !plugin[handler]) {
messageFormat.attach(link);
} else {
messageFormat.attach(link, async function(message, format) {
return await plugin[handler](message, format, this);
});
} else {
messageFormat.attach(link, async function(message, format) {
return await plugin[handler](message, format, this);
});
}
} catch (err) {
if (err.code === "MISSING_LINK_HANDLER") {
err.plugin = pluginInfo.name;
err.handler = handler;
}
throw err;
}
}
}