mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Fix constants errors not giving a stacktrace
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user