Sha256: 430f32b0d60f6ef4840d3e29929fc29589ca5ba4a974e836bb06bccb9c90e7fe

Contents?: true

Size: 1008 Bytes

Versions: 26

Compression:

Stored size: 1008 Bytes

Contents

"use strict";

const WebpackError = require("./WebpackError");
const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;

/**
 * @param {string=} method method name
 * @returns {string} message
 */
function createMessage(method) {
	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();
}

/**
 * Error for abstract method
 * @example
 * class FooClass {
 *     abstractMethod() {
 *         throw new AbstractMethodError(); // error message: Abstract method FooClass.abstractMethod. Must be overriden.
 *     }
 * }
 *
 */
class AbstractMethodError extends WebpackError {
	constructor() {
		super(new Message().message);
		this.name = "AbstractMethodError";
	}
}

module.exports = AbstractMethodError;

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.18.0 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.18.2 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.16.1 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.15.2 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.18.4 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.18.1 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.14.0 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/webpack/lib/AbstractMethodError.js
tang-0.2.1 spec/tang_app/node_modules/webpack/lib/AbstractMethodError.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/webpack/lib/AbstractMethodError.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/webpack/lib/AbstractMethodError.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/webpack/lib/AbstractMethodError.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/webpack/lib/AbstractMethodError.js
tang-0.2.0 spec/tang_app/node_modules/webpack/lib/AbstractMethodError.js
tang-0.1.0 spec/tang_app/node_modules/webpack/lib/AbstractMethodError.js
tang-0.0.9 spec/tang_app/node_modules/webpack/lib/AbstractMethodError.js
enju_library-0.3.8 spec/dummy/node_modules/webpack/lib/AbstractMethodError.js
jester-data-8.0.0 node_modules/webpack/lib/AbstractMethodError.js