https://github.com/flasd/smart-error
Show rich error messages during development and vague messages in production.
https://github.com/flasd/smart-error
Last synced: over 1 year ago
JSON representation
Show rich error messages during development and vague messages in production.
- Host: GitHub
- URL: https://github.com/flasd/smart-error
- Owner: flasd
- License: mit
- Created: 2019-01-15T19:45:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-15T20:53:35.000Z (over 7 years ago)
- Last Synced: 2025-01-22T01:41:26.041Z (over 1 year ago)
- Language: JavaScript
- Size: 159 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Smart Error
Show rich error messages during development and vague messages in production.
[](https://travis-ci.org/@flasd/smart-error)
[](https://coveralls.io/github/@flasd/smart-error?branch=master)
[](https://www.npmjs.com/package/@flasd/smart-error)
[](https://www.npmjs.com/package/@flasd/smart-error)
### Instalation
Install the latest version using NPM:
```sh
npm install @flasd/smart-error
```
### Usage
```javascript
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:
```javascript
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 :1:7
//
```
If you'd want to remove the reporting listener:
```javascript
import SmartError from "@flasd/smart-error";
const removeListener = SmartError.setReportFunction(error => {});
removeListener();
```
### Copyright e Licença
Copyright (c) 2019 [Marcel de Oliveira Coelho](https://github.com/flasd) under the [MIT License](https://github.com/flasd/smart-error/blob/master/LICENSE.md). Go Crazy. :rocket: