Update autoVersion.js to emit errors instead of throwing

This commit is contained in:
Ethan Davis 2018-01-15 20:30:50 -08:00
parent eef401c1c8
commit 01f8342f9e

View File

@ -11,7 +11,7 @@ module.exports = function(client, options) {
debug('pinging',options.host);
// TODO: use 0xfe ping instead for better compatibility/performance? https://github.com/deathcap/node-minecraft-ping
ping(options, function(err, response) {
if (err) throw err; // hmm
client.emit('error',err);
debug('ping response',response);
// TODO: could also use ping pre-connect to save description, type, max players, etc.
const motd = response.description;
@ -30,7 +30,7 @@ module.exports = function(client, options) {
.sort(function (a, b) { return b.version - a.version })
.concat(minecraft_data.postNettyVersionsByProtocolVersion["pc"][protocolVersion]||[])
if (versions.length === 0) {
throw new Error(`unsupported/unknown protocol version: ${protocolVersion}, update minecraft-data`);
client.emit('error',`unsupported/unknown protocol version: ${protocolVersion}, update minecraft-data`);
}
const minecraftVersion = versions[0].minecraftVersion;