1.1.0 • Published 5 years ago

@flasd/smart-error v1.1.0

Weekly downloads
-
License
-
Repository
-
Last release
5 years ago

Smart Error

Show rich error messages during development and vague messages in production.

Build Status Coverage Status npm version npm downloads per month

Instalation

Install the latest version using NPM:

npm install @flasd/smart-error

Usage

import SmartError from "@flasd/smart-error";

throw new SmartError(/* regular error params */);

Additionaly you can pass a callback to get called anytime you call the constructor:

import SmartError from "@flasd/smart-error";

SmartError.setReportFunction(error => {
  // do your magic! You can throw erros here, we'll catch them for you.
  // this function can even be async (return a promise!)

  console.error(error);
});

throw new SmartError("miau");
// VM1:1 Uncaught Error: miau
//  at <anonymous>:1:7
//

If you'd want to remove the reporting listener:

import SmartError from "@flasd/smart-error";

const removeListener = SmartError.setReportFunction(error => {});

removeListener();

Copyright e Licença

Copyright (c) 2019 Marcel de Oliveira Coelho under the MIT License. Go Crazy. :rocket: