https://github.com/ember-cli/silent-error
https://github.com/ember-cli/silent-error
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ember-cli/silent-error
- Owner: ember-cli
- License: isc
- Created: 2015-06-03T19:59:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-08-01T03:14:38.000Z (over 4 years ago)
- Last Synced: 2025-05-28T08:20:57.646Z (8 months ago)
- Language: JavaScript
- Size: 33.2 KB
- Stars: 5
- Watchers: 8
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# silent-error [](https://travis-ci.org/ember-cli/silent-error)
An error subclass for humanized errors. This module allows for inter-module detection of errors which are fatal, but where a stacktrace by default provides negative value.
Some use-cases:
* command in your CLI tool is missing
* plugin to your build system is given invalid user-input.
Obviously stack traces can still be valuable. To view the stacks, the following environment variable can be set to `true`
```
SILENT_ERROR=verbose
```
## Example
```js
// in one node module
async function runCommand(name) {
// some logic
throw new SilentError(`command: '${name}' is not installed`);
}
```
```js
// in another node_module
async function caller() {
try {
await runCommand('foo');
} catch(e) {
SilentError.debugOrThrow(e);
}
SilentError.debugOrThrow
}
```
## Installation
```
yarn add silent-error
```
or
```
npm install --save silent-error
```