Show a nicer error in Chan.loadMessages() when network is misconfigured (#4476)

Show a nicer error in Chan.loadMessages() when network is misconfigured

ie. an actual error message instead of crashing on a `null` value.
This commit is contained in:
Val Lorentz 2022-02-17 01:27:41 +01:00 committed by GitHub
parent c12dd6c740
commit 66455f2c40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,6 +241,14 @@ Chan.prototype.loadMessages = function (client, network) {
return;
}
if (!network.irc) {
// Network created, but misconfigured
log.warn(
`Failed to load messages for ${client.name}, network ${network.name} is not initialized.`
);
return;
}
client.messageProvider
.getMessages(network, this)
.then((messages) => {
@ -270,7 +278,7 @@ Chan.prototype.loadMessages = function (client, network) {
requestZncPlayback(this, network, from);
}
})
.catch((err) => log.error(`Failed to load messages: ${err}`));
.catch((err) => log.error(`Failed to load messages for ${client.name}: ${err}`));
};
Chan.prototype.isLoggable = function () {