mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 13:33:30 +01:00
feat(BitField): move problematic bit into the error message (#5228)
* feat(BitField): move problematic bit into the error message * fix: remove intermediate constant
This commit is contained in:
@@ -13,7 +13,7 @@ const Messages = {
|
|||||||
WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
|
WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
|
||||||
WS_NOT_OPEN: (data = 'data') => `Websocket not open to send ${data}`,
|
WS_NOT_OPEN: (data = 'data') => `Websocket not open to send ${data}`,
|
||||||
|
|
||||||
BITFIELD_INVALID: 'Invalid bitfield flag or number.',
|
BITFIELD_INVALID: bit => `Invalid bitfield flag or number: ${bit}.`,
|
||||||
|
|
||||||
SHARDING_INVALID: 'Invalid shard settings were provided.',
|
SHARDING_INVALID: 'Invalid shard settings were provided.',
|
||||||
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
|
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
|
||||||
|
|||||||
@@ -147,9 +147,7 @@ class BitField {
|
|||||||
if (bit instanceof BitField) return bit.bitfield;
|
if (bit instanceof BitField) return bit.bitfield;
|
||||||
if (Array.isArray(bit)) return bit.map(p => this.resolve(p)).reduce((prev, p) => prev | p, 0);
|
if (Array.isArray(bit)) return bit.map(p => this.resolve(p)).reduce((prev, p) => prev | p, 0);
|
||||||
if (typeof bit === 'string' && typeof this.FLAGS[bit] !== 'undefined') return this.FLAGS[bit];
|
if (typeof bit === 'string' && typeof this.FLAGS[bit] !== 'undefined') return this.FLAGS[bit];
|
||||||
const error = new RangeError('BITFIELD_INVALID');
|
throw new RangeError('BITFIELD_INVALID', bit);
|
||||||
error.bit = bit;
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user