From afcf43aef62148e164652ac4c32f1613d5cd7557 Mon Sep 17 00:00:00 2001 From: aemino Date: Mon, 3 Jul 2017 15:09:38 -0700 Subject: [PATCH] Add VoiceConnection errors (#1649) --- src/client/voice/VoiceConnection.js | 8 ++++---- src/errors/Messages.js | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index 903ed9ad0..f4ed1b16f 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -177,14 +177,14 @@ class VoiceConnection extends EventEmitter { } if (!token) { - this.authenticateFailed('Token not provided from voice server packet.'); + this.authenticateFailed('VOICE_TOKEN_ABSENT'); return; } endpoint = endpoint.match(/([^:]*)/)[0]; if (!endpoint) { - this.authenticateFailed('Invalid endpoint received.'); + this.authenticateFailed('VOICE_INVALID_ENDPOINT'); return; } @@ -203,7 +203,7 @@ class VoiceConnection extends EventEmitter { */ setSessionID(sessionID) { if (!sessionID) { - this.authenticateFailed('Session ID not supplied.'); + this.authenticateFailed('VOICE_SESSION_ABSENT'); return; } @@ -277,7 +277,7 @@ class VoiceConnection extends EventEmitter { authenticate() { this.sendVoiceStateUpdate(); this.connectTimeout = this.client.setTimeout( - () => this.authenticateFailed(new Error('Connection not established within 15 seconds.')), 15000); + () => this.authenticateFailed('VOICE_CONNECTION_TIMEOUT'), 15000); } /** diff --git a/src/errors/Messages.js b/src/errors/Messages.js index ffaaec720..36ac8235b 100644 --- a/src/errors/Messages.js +++ b/src/errors/Messages.js @@ -47,6 +47,10 @@ const Messages = { VOICE_STREAM_EXISTS: 'There is already an existing stream for that user.', VOICE_JOIN_CHANNEL: (full = false) => `You do not have permission to join this voice channel${full ? '; it is full.' : '.'}`, + VOICE_CONNECTION_TIMEOUT: 'Connection not established within 15 seconds.', + VOICE_TOKEN_ABSENT: 'Token not provided from voice server packet.', + VOICE_SESSION_ABSENT: 'Session ID not supplied.', + VOICE_INVALID_ENDPOINT: 'Invalid endpoint received.', OPUS_ENGINE_MISSING: 'Couldn\'t find an Opus engine.',