#9391 resolve super call discussion
This commit is contained in:
parent
bd7d95bfc1
commit
bf1a24a9ab
|
@ -71,7 +71,8 @@ module.exports = {
|
|||
};
|
||||
return acc;
|
||||
}, {})),
|
||||
extends: "extends"
|
||||
extends: "extends",
|
||||
constructor: "constructor"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -8,7 +8,19 @@ const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;
|
|||
* @returns {string} message
|
||||
*/
|
||||
function createMessage(method) {
|
||||
return `Abstract method${method ? " " + method : ""}. Must be overriden.`;
|
||||
return `Abstract method${method ? " " + method : ""}. Must be overridden.`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Message() {
|
||||
this.stack = undefined;
|
||||
Error.captureStackTrace(this);
|
||||
/** @type {RegExpMatchArray} */
|
||||
const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP);
|
||||
|
||||
this.message = match && match[1] ? createMessage(match[1]) : createMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,13 +35,8 @@ function createMessage(method) {
|
|||
*/
|
||||
class AbstractMethodError extends WebpackError {
|
||||
constructor() {
|
||||
super(createMessage());
|
||||
super(new Message().message);
|
||||
this.name = "AbstractMethodError";
|
||||
/** @type {RegExpMatchArray} */
|
||||
const match = this.stack.split("\n")[1].match(CURRENT_METHOD_REGEXP);
|
||||
if (match && match[1]) {
|
||||
this.message = createMessage(match[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ describe("WebpackError", () => {
|
|||
|
||||
class Child extends Foo {}
|
||||
|
||||
const expectedMessage = "Abstract method $1. Must be overriden.";
|
||||
const expectedMessage = "Abstract method $1. Must be overridden.";
|
||||
|
||||
it("Should construct message with caller info", () => {
|
||||
const fooClassError = new Foo().abstractMethod();
|
||||
|
|
Loading…
Reference in New Issue