Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extendable Error

YOU PROBABLY DON'T NEED THIS PACKAGE ANYMORE.

The 6 lines of code below works well enough in modern JavaScript engines:

export abstract class ExtendableError extends Error {
  constructor(message?: string) {
    super(message);
    this.name = new.target.name;
  }
}

A simple abstract extendable error class that extends Error, which handles the error name, message and stack property.

Install

npm install extendable-error --save

Usage

import ExtendableError from "extendable-error";

class SomeError extends ExtendableError {
  constructor(message: string, public code: number) {
    super(message);
  }
}

let someError = new SomeError("Some error", 0x0001);

License

MIT License.

About

A simple extendable error class that extends Error.

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages