
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
extendable-error-class
Advanced tools
Extend the Error Class with ES2015/ES5/Babel, i.e. fix for `class MyError extends Error{}`
const ExtendableError = require('extendable-error-class');
class MyError extends ExtendableError {
constructor(m) {
super(m);
// Optional - ExtendableError sets `name` to your class's name itself,
// but minification, etc. can change that, so you may want to do it
// explicitly.
this.name = 'MyError';
}
}
extendable-error-class has no dependencies.
Because the following doesn't work as expected.
class MyError extends Error {
constructor(m) {
super(m);
}
}
The workaround is based on babel-plugin-transform-builtin-extend and following code
const ExtendableError = class extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = (new Error(message)).stack;
}
}
};
The code is already compiled with babel and babel-plugin-transform-builtin-extend. Therefore one is able to use this workaround without adding any dependency.
See http://stackoverflow.com/questions/31089801/extending-error-in-javascript-with-es6-syntax
FAQs
Extend the Error Class with ES2015/ES5/Babel, i.e. fix for `class MyError extends Error{}`
The npm package extendable-error-class receives a total of 93 weekly downloads. As such, extendable-error-class popularity was classified as not popular.
We found that extendable-error-class demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.