I have made a error class hierarchy, starting with a BaseError class that is purely meant for subclassing. I have set the prototype using Object.create(Error.prototype) and I am rewriting the stack using the name of the current subclass. The name is set in a method called configure that needs to be implemented by the subclasses.
The problem is that although I explicitly add the configure method to the prototype of BaseError it is not actually accessible in the prototype chain.
I think it is somehow related to the __proto__ instance property vs the prototype attribute.
This is the code (transpiled from the Typescript definition)
var BaseError = (function () {
function BaseError(msg) {
var err = Error.apply(null, arguments);
this.message = err.message;
this.configure();
if (err.stack) {
this.stack = rewriteStack(err.stack, this.name);
}
if (typeof this.name === 'undefined')
throw new NotImplementedError('must set "name" property in the configure call');
}
return BaseError;
})();
Framework.BaseError = BaseError;
// weird stuff need to happen to make BaseError pass an "instanceof Error"
BaseError.prototype = Object.create(Error.prototype);
BaseError.prototype.configure = function () {
throw new NotImplementedError(+' This method must be implemented in the overriding class!');
};

