0.1.0-beta.3 • Published 11 months ago

@alliage/error-handler v0.1.0-beta.3

Weekly downloads
-
License
GNU
Repository
github
Last release
11 months ago

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.

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 debug 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 uncaught
    this.status = status;
    this.body = body;
  }
}

// Later...

throw new HttpError(404, 'Not found');
0.1.0-beta.3

11 months ago

0.1.0-beta.2

11 months ago

0.1.0-beta.1

1 year ago

0.1.0-beta.0

1 year ago