mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fix constants errors not giving a stacktrace
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -142,7 +142,7 @@ class ClientDataResolver {
|
||||
*/
|
||||
resolvePermission(permission) {
|
||||
if (typeof permission === 'string') permission = Constants.PermissionFlags[permission];
|
||||
if (!permission) throw Constants.Errors.NOT_A_PERMISSION;
|
||||
if (!permission) throw new Error(Constants.Errors.NOT_A_PERMISSION);
|
||||
return permission;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class ClientManager {
|
||||
this.client.ws.connect(gateway);
|
||||
this.client.once(Constants.Events.READY, () => resolve(token));
|
||||
}).catch(reject);
|
||||
this.client.setTimeout(() => reject(Constants.Errors.TOOK_TOO_LONG), 1000 * 300);
|
||||
this.client.setTimeout(() => reject(new Error(Constants.Errors.TOOK_TOO_LONG)), 1000 * 300);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ class APIRequest {
|
||||
} else if (this.rest.client.token) {
|
||||
return this.rest.client.token;
|
||||
}
|
||||
throw Constants.Errors.NO_TOKEN;
|
||||
throw new Error(Constants.Errors.NO_TOKEN);
|
||||
}
|
||||
|
||||
gen() {
|
||||
|
||||
@@ -29,7 +29,7 @@ class RESTManager {
|
||||
case 'sequential':
|
||||
return SequentialRequestHandler;
|
||||
default:
|
||||
throw Constants.Errors.INVALID_RATE_LIMIT_METHOD;
|
||||
throw new Error(Constants.Errors.INVALID_RATE_LIMIT_METHOD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class WebSocketManager {
|
||||
* @param {Object} event The received websocket data
|
||||
*/
|
||||
eventClose(event) {
|
||||
if (event.code === 4004) throw Constants.Errors.BAD_LOGIN;
|
||||
if (event.code === 4004) throw new Error(Constants.Errors.BAD_LOGIN);
|
||||
if (!this.reconnecting && event.code !== 1000) this.tryReconnect();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ class WebSocketManager {
|
||||
if (event.binary) event.data = zlib.inflateSync(event.data).toString();
|
||||
packet = JSON.parse(event.data);
|
||||
} catch (e) {
|
||||
return this.eventError(Constants.Errors.BAD_WS_MESSAGE);
|
||||
return this.eventError(new Error(Constants.Errors.BAD_WS_MESSAGE));
|
||||
}
|
||||
|
||||
this.client.emit('raw', packet);
|
||||
|
||||
@@ -63,13 +63,13 @@ exports.ChannelTypes = {
|
||||
exports.Package = require('../../package.json');
|
||||
|
||||
exports.Errors = {
|
||||
NO_TOKEN: new Error('request to use token, but token was unavailable to the client'),
|
||||
NO_BOT_ACCOUNT: new Error('you should ideally be using a bot account!'),
|
||||
BAD_WS_MESSAGE: new Error('a bad message was received from the websocket - bad compression or not json'),
|
||||
TOOK_TOO_LONG: new Error('something took too long to do'),
|
||||
NOT_A_PERMISSION: new Error('that is not a valid permission string or number'),
|
||||
INVALID_RATE_LIMIT_METHOD: new Error('unknown rate limiting method'),
|
||||
BAD_LOGIN: new Error('incorrect login details were provided'),
|
||||
NO_TOKEN: 'request to use token, but token was unavailable to the client',
|
||||
NO_BOT_ACCOUNT: 'you should ideally be using a bot account!',
|
||||
BAD_WS_MESSAGE: 'a bad message was received from the websocket - bad compression or not json',
|
||||
TOOK_TOO_LONG: 'something took too long to do',
|
||||
NOT_A_PERMISSION: 'that is not a valid permission string or number',
|
||||
INVALID_RATE_LIMIT_METHOD: 'unknown rate limiting method',
|
||||
BAD_LOGIN: 'incorrect login details were provided',
|
||||
};
|
||||
|
||||
const API = `https://discordapp.com/api/v${exports.DefaultOptions.protocol_version}`;
|
||||
|
||||
Reference in New Issue
Block a user