Use AbstractMethodError all over the project
This commit is contained in:
parent
2c4131974d
commit
7a3d9e38de
|
@ -5,6 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const AbstractMethodError = require("./AbstractMethodError");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
|
@ -34,7 +36,7 @@ class DependencyTemplate {
|
|||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
throw new Error("DependencyTemplate.apply must be overriden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const AbstractMethodError = require("./AbstractMethodError");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
||||
|
@ -36,7 +38,7 @@ class Generator {
|
|||
* @returns {Set<string>} available types (do not mutate)
|
||||
*/
|
||||
getTypes() {
|
||||
throw new Error("Generator.getTypes: must be overridden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +48,7 @@ class Generator {
|
|||
* @returns {number} estimate size of the module
|
||||
*/
|
||||
getSize(module, type) {
|
||||
throw new Error("Generator.getSize: must be overridden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +61,7 @@ class Generator {
|
|||
module,
|
||||
{ dependencyTemplates, runtimeTemplate, moduleGraph, type }
|
||||
) {
|
||||
throw new Error("Generator.generate: must be overridden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const AbstractMethodError = require("./AbstractMethodError");
|
||||
const ChunkGraph = require("./ChunkGraph");
|
||||
const DependenciesBlock = require("./DependenciesBlock");
|
||||
const ModuleGraph = require("./ModuleGraph");
|
||||
|
@ -496,7 +497,7 @@ class Module extends DependenciesBlock {
|
|||
* @returns {string} a unique identifier of the module
|
||||
*/
|
||||
identifier() {
|
||||
throw new Error("Module.identifier: Must be overriden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,7 +506,7 @@ class Module extends DependenciesBlock {
|
|||
* @returns {string} a user readable identifier of the module
|
||||
*/
|
||||
readableIdentifier(requestShortener) {
|
||||
throw new Error("Module.readableIdentifier: Must be overriden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -518,7 +519,7 @@ class Module extends DependenciesBlock {
|
|||
* @returns {void}
|
||||
*/
|
||||
build(options, compilation, resolver, fs, callback) {
|
||||
throw new Error("Module.build: Must be overriden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -542,7 +543,7 @@ class Module extends DependenciesBlock {
|
|||
*/
|
||||
source(sourceContext) {
|
||||
if (this.codeGeneration === Module.prototype.codeGeneration) {
|
||||
throw new Error("Module.source: Must be overriden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
const sources = this.codeGeneration(sourceContext).sources;
|
||||
return sourceContext.type
|
||||
|
@ -560,7 +561,7 @@ class Module extends DependenciesBlock {
|
|||
* @returns {number} the estimated size of the module (must be non-zero)
|
||||
*/
|
||||
size(type) {
|
||||
throw new Error("Module.size: Must be overriden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const AbstractMethodError = require("./AbstractMethodError");
|
||||
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
|
@ -37,7 +39,7 @@ class ModuleFactory {
|
|||
* @returns {void}
|
||||
*/
|
||||
create(data, callback) {
|
||||
throw new Error("ModuleFactory.create must be overridden");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"use strict";
|
||||
|
||||
const OriginalSource = require("webpack-sources").OriginalSource;
|
||||
const AbstractMethodError = require("./AbstractMethodError");
|
||||
const Module = require("./Module");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
|
@ -146,9 +147,7 @@ class RuntimeModule extends Module {
|
|||
* @returns {string} runtime code
|
||||
*/
|
||||
generate() {
|
||||
throw new Error(
|
||||
`RuntimeModule: generate() must be overriden in subclass ${this.name}`
|
||||
);
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue