1.3.1 • Published 3 years ago

alliage-error-handler v1.3.1

Weekly downloads
8
License
GNU
Repository
github
Last release
3 years ago

Alliage Error Handler

alliage-error-handler

Module allowing to display exceptions gracefully.

Installation

yarn add alliage-error-handler

With npm

npm install alliage-error-handler

Registration

If you have already installed alliage-module-installer you just have to run the following command:

$(npm bin)/alliage-scripts install alliage-error-handler

Otherwise, update your alliage-modules.json file to add this at the bottom:

{
  // ... other modules
  "alliage-error-handler": {
    "module": "alliage-error-handler",
    "deps": [],
    "envs": [],
  }
}

Usage

Once installed and registered, the module will work right away without having to do anything specific to do.

The goal of this module is to display as much details as possible about uncaught exceptions or unhandled rejections. Basically, it will display:

  • The name of the error (class name)
  • The message
  • The stacktrace
  • Any public property that is not part of the Error prototype.

So, if you write your own alliage module, don't hesitate to create your custom Error classes and to add as much context as possible in it to let the developers using your module debut their application easily !

Example:

class HttpError extends Error {
  constructor(status, body) {
    super('An HTTP error occured !');

    // These two additional properties will
    // be displayed if the error is incaught
    this.status = status;
    this.body = body;
  }
}

// Later...

throw new HttpError(404, 'Not found');
1.3.1-beta.0

3 years ago

1.3.0-beta.2

3 years ago

1.3.0-beta.5

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0-pre1

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago