es6-error

WebJar for es6-error

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

es6-error
Last Version

Last Version

4.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

es6-error
WebJar for es6-error
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/bjyoungblood/es6-error

Download es6-error

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/es6-error/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>es6-error</artifactId>
    <version>4.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/es6-error/
implementation 'org.webjars.npm:es6-error:4.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/es6-error/
implementation ("org.webjars.npm:es6-error:4.1.1")
'org.webjars.npm:es6-error:jar:4.1.1'
<dependency org="org.webjars.npm" name="es6-error" rev="4.1.1">
  <artifact name="es6-error" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='es6-error', version='4.1.1')
)
libraryDependencies += "org.webjars.npm" % "es6-error" % "4.1.1"
[org.webjars.npm/es6-error "4.1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Versions

Version
4.1.1
4.0.0
3.2.0