I am trying to extend Error with ES6 and Babel. It isn\'t working out.
class MyError extends Error {
constructor(m) {
super(m);
}
}
var error = new
As @sukima mentions, you cannot extend native JS. The OP's question cannot be answered.
Similar to Melbourne2991's answer, I did used a factory rather, but followed MDN's recommendation for customer error types.
function extendError(className){
function CustomError(message){
this.name = className;
this.message = message;
this.stack = new Error().stack; // Optional
}
CustomError.prototype = Object.create(Error.prototype);
CustomError.prototype.constructor = CustomError;
return CustomError;
}