Need help with es6-error?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

bjyoungblood
216 Stars 30 Forks MIT License 63 Commits 6 Opened issues

Description

Easily-extendable error for use with ES6 classes

Services available

!
?

Need anything else?

Contributors list

# 277,671
Shell
HTML
mustach...
Erlang
31 commits
# 316,111
JavaScr...
eventem...
HTML
Gulp
5 commits
# 110,796
JavaScr...
Webpack
Shell
React
2 commits
# 12,467
Node.js
ESLint
ecmascr...
React N...
2 commits
# 78,966
boilerp...
Go
HTML
postman...
2 commits
# 187,593
JavaScr...
CSS
fetch
React
1 commit
# 1,952
JavaScr...
appium
iOS
C#
1 commit
# 1,754
Babel
autopre...
lodash
React
1 commit
# 7,299
JavaScr...
React
Redux
scaffol...
1 commit
# 215,264
HTML
Shell
scss
sass-mi...
1 commit
# 21,462
typescr...
TypeScr...
coffees...
redux-m...
1 commit

es6-error

npm version Build Status

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

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

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)

Todo

  • Better browser compatibility
  • Browser tests

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.