mirror of
https://github.com/danbulant/discord.js
synced 2026-05-30 12:51:55 +00:00
Improve structure extension errors
This commit is contained in:
parent
b74a4356dd
commit
04fa56d0c0
1 changed files with 9 additions and 4 deletions
|
|
@ -45,17 +45,22 @@ class Structures {
|
|||
if (typeof extender !== 'function') {
|
||||
const received = `(received ${typeof extender})`;
|
||||
throw new TypeError(
|
||||
`"extender" argument must be a function that returns the extended structure class/prototype ${received}`
|
||||
`"extender" argument must be a function that returns the extended structure class/prototype ${received}.`
|
||||
);
|
||||
}
|
||||
|
||||
const extended = extender(structures[structure]);
|
||||
if (typeof extended !== 'function') {
|
||||
throw new TypeError('The extender function must return the extended structure class/prototype.');
|
||||
const received = `(received ${typeof extended})`;
|
||||
throw new TypeError(`The extender function must return the extended structure class/prototype ${received}.`);
|
||||
}
|
||||
if (Object.getPrototypeOf(extended) !== structures[structure]) {
|
||||
|
||||
const prototype = Object.getPrototypeOf(extended);
|
||||
if (prototype !== structures[structure]) {
|
||||
const received = `${extended.name || 'unnamed'}${prototype.name ? ` extends ${prototype.name}` : ''}`;
|
||||
throw new Error(
|
||||
'The class/prototype returned from the extender function must extend the existing structure class/prototype.'
|
||||
'The class/prototype returned from the extender function must extend the existing structure class/prototype' +
|
||||
` (received function ${received}; expected extension of ${structures[structure].name}).`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue