@flasd/smart-error

1.1.0 • Public • Published

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. 🚀

Readme

Keywords

none

Package Sidebar

Install

npm i @flasd/smart-error

Weekly Downloads

1

Version

1.1.0

License

none

Unpacked Size

50.5 kB

Total Files

9

Last publish

Collaborators

  • husscode