KADABRA API

LARA API

LARA Common Language API

(.js)
laraImport("lara.util.AbstractClassError");

(.lara)
import lara.util.AbstractClassError;

AbstractClassError

Constructor

AbstractClassError

new AbstractClassError()

(Extends Error)
Custom error to be thrown when derived classes do not extend an abstract class correctly.

To use the error correctly, write something like:

```js
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:


Instance Members

constructor

constructor(options, options.kind, options.baseClass, options.derivedClass, options.method)

Parameters

options: any - Options to construct the error
options.kind: "constructor"|"abstractMethod" - Whether the error is being thrown by an abstract constructor or method
options.baseClass: any - The base abstract class
options.derivedClass: any - The derived class. Only used when building an error for an abstract method.
options.method: any - The method that is not implemented. Only used when building an error for an abstract method.