Custom error to be thrown when derived classes do not extend an abstract class correctly.
To use the error correctly, write something like:
class AnAbstractClass { constructor() { if (this.constructor === AnAbstractClass) { throw new AbstractClassError({ kind: "constructor", baseClass: AnAbstractClass, }); // message: "AbstractClassError: Cannot instantiate abstract class AnAbstractClass." } } notImplementedMethod() { throw new AbstractClassError({ kind: "abstractMethod", baseClass: AnAbstractClass, derivedClass: this.constructor, method: this.notImplementedMethod, }); // message: "AbstractClassError: Derived class ADerivedClass has not implemented abstract method AnAbstractClass::notImplementedMethod." }} Copy
class AnAbstractClass { constructor() { if (this.constructor === AnAbstractClass) { throw new AbstractClassError({ kind: "constructor", baseClass: AnAbstractClass, }); // message: "AbstractClassError: Cannot instantiate abstract class AnAbstractClass." } } notImplementedMethod() { throw new AbstractClassError({ kind: "abstractMethod", baseClass: AnAbstractClass, derivedClass: this.constructor, method: this.notImplementedMethod, }); // message: "AbstractClassError: Derived class ADerivedClass has not implemented abstract method AnAbstractClass::notImplementedMethod." }}
Formats a message like: "AbstractClassError:
Optional
Static
Optional override for formatting stack traces
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Create .stack property on a target object
Custom error to be thrown when derived classes do not extend an abstract class correctly.
To use the error correctly, write something like:
Example
Formats a message like: "AbstractClassError: