Skip to content

Commit

Permalink
📝 add LICENSE.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
necojackarc committed Oct 7, 2018
1 parent e880038 commit 9be00e1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 necojackarc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Extensible Custom Error

[![npm version](https://badge.fury.io/js/extensible-custom-error.svg)](https://badge.fury.io/js/extensible-custom-error)
[![Build Status](https://travis-ci.com/necojackarc/extensible-custom-error.svg?branch=master)](https://travis-ci.com/necojackarc/extensible-custom-error)
[![Coverage Status](https://coveralls.io/repos/github/necojackarc/extensible-custom-error/badge.svg?branch=master)](https://coveralls.io/github/necojackarc/extensible-custom-error?branch=master)
Expand Down Expand Up @@ -26,8 +27,10 @@ new MyError('message', error); // Take a message and an error
* [Wrap an error](#wrap-an-error)
* [Wrap an error while passing a new message](#wrap-an-error-while-passing-a-new-message)
* [Special Thanks](#special-thanks)
* [License](#license)

## Notable Features

There are some pains around JavaScript error handling.
Two of them are:

Expand All @@ -37,6 +40,7 @@ Two of them are:
This `ExtensibleCustomError` class enables you to do both - you can define your custom errors easily and wrap errors with them while merging stack traces prettily.

### Define custom errors easily

To define custom errors in Vanilla JS, you need to set names and stack traces manually, but you no longer need to do that with `ExtensibleCustomError`.

```js
Expand All @@ -46,6 +50,7 @@ class MyError extends ExtensibleCustomError {}
N.B. With an uglifier, class names might get obsecure. See [this issue comment](https://github.com/bjyoungblood/es6-error/issues/31#issuecomment-301128220).

### Wrap errors without losing any data

Built-in errors only take a message, so they can't wrap any errors, which means stack traces so far will be lost.
However, `ExtensibleCustomError` can take a message and/or an Error object while merging stack traces.

Expand Down Expand Up @@ -78,6 +83,7 @@ $ yarn add extensible-custom-error
## Usage

### Define custom errors

```js
const ExtensibleCustomError = require('extensible-custom-error');

Expand All @@ -103,6 +109,7 @@ class MyErrorWithCustomProperty extends ExtensibleCustomError {
```

### Instantiate custom errors

You can instantiate your custom errors in the same way as built-in errors.

```js
Expand Down Expand Up @@ -131,6 +138,7 @@ try {
## Examples

### Wrap an error

If you run:

```js
Expand Down Expand Up @@ -230,5 +238,10 @@ Error: Have withstood Pain to create many Weapons
```

## Special Thanks

* [@yszk0123](https://github.com/yszk0123) as a reviewer
* [bjyoungblood/es6-error](https://github.com/bjyoungblood/es6-error) as a reference

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

0 comments on commit 9be00e1

Please sign in to comment.