diff options
author | LinuxWizard42 <computerwizard@linuxmail.org> | 2022-10-12 22:54:37 +0300 |
---|---|---|
committer | LinuxWizard42 <computerwizard@linuxmail.org> | 2022-10-12 22:54:37 +0300 |
commit | 703e03aba33f234712206769f57717ba7d92d23d (patch) | |
tree | 0041f04ccb75bd5379c764e9fe42249fffe75fc3 /node_modules/es6-error/README.md | |
parent | ab6e257e6e9d9a483d7e86f220d8b209a2cd7753 (diff) | |
download | FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.gz FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.zst |
Added export_allowed file to make repository visible in cgit
Diffstat (limited to 'node_modules/es6-error/README.md')
-rw-r--r-- | node_modules/es6-error/README.md | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/node_modules/es6-error/README.md b/node_modules/es6-error/README.md new file mode 100644 index 0000000..8a8f130 --- /dev/null +++ b/node_modules/es6-error/README.md @@ -0,0 +1,59 @@ +# es6-error + +[](https://www.npmjs.com/package/es6-error) +[](https://travis-ci.org/bjyoungblood/es6-error) + +An easily-extendable error class for use with ES6 classes (or ES5, if you so +choose). + +Tested in Node 4.0, Chrome, and Firefox. + +## Why? + +I made this because I wanted to be able to extend Error for inheritance and type +checking, but can never remember to add +`Error.captureStackTrace(this, this.constructor.name)` to the constructor or how +to get the proper name to print from `console.log`. + +## ES6 Usage + +```javascript + +import ExtendableError from 'es6-error'; + +class MyError extends ExtendableError { + // constructor is optional; you should omit it if you just want a custom error + // type for inheritance and type checking + constructor(message = 'Default message') { + super(message); + } +} + +export default MyError; +``` + +## ES5 Usage + +```javascript + +var util = require('util'); +var ExtendableError = require('es6-error'); + +function MyError(message) { + message = message || 'Default message'; + ExtendableError.call(this, message); +} + +util.inherits(MyError, ExtendableError); + +module.exports = MyError; +``` + +### Known Issues + +- Uglification can obscure error class names ([#31](https://github.com/bjyoungblood/es6-error/issues/31#issuecomment-301128220)) + +#### Todo + +- Better browser compatibility +- Browser tests |