abstract-class-error
v3.0.0
Published
An error designed for being thrown when a class is instantiated, an object created, or a method is not overridden that, was intended to be abstract.
Downloads
7
Maintainers
Readme
AbstractConstructError
An error designed for being thrown when a class is instantiated, an object created, or a method is not overridden that, was intended to be abstract.
import AbstractConstructError from 'abstract-class-error';
class AbstractParent {
constructor() {
if (new.target === AbstractParent) {
throw new AbstractConstructError('Cannot construct class AbstractParent instances directly');
}
if (this.abstractMethod === AbstractParent.prototype.abstractMethod) {
throw new AbstractConstructError('Method "abstractMethod" must be overridden in class AbstractParent');
}
}
abstractMethod() {}
}
Feedback ✉️
https://github.com/limeandcoconut
Cheers!
License
ISC, see license for details.
Usage
License
ISC, see LICENSE.md for details.