Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

babel-plugin-native-error-extend

Build Status

Babel plugin for native Error extending.

Handles all ususal cases such as classic extend and constructor override.

Install

npm install babel-plugin-native-error-extend --save

Usage

Use it via available [plugin activation options][babel-plugins].

For .babelrc file:

{
	"plugins": ["babel-plugin-native-error-extend"]
}

Then, in your code:

/* Before */

class Becky extends Error {}

/* After */

class Becky 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;
		}
	}
}

Check test fixtures (actual and expected) for more examples.

Acknowledgments

License

MIT © Ivan Nikolić

About

Babel plugin for native `Error` extending.

Resources

License

Packages

No packages published
You can’t perform that action at this time.