UNPKG

1.02 kBMarkdownView Raw
1# silent-error [![Build Status](https://travis-ci.org/ember-cli/silent-error.svg)](https://travis-ci.org/ember-cli/silent-error)
2
3An 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.
4
5Some use-cases:
6
7* command in your CLI tool is missing
8* plugin to your build system is given invalid user-input.
9
10Obviously stack traces can still be valuable. To view the stacks, the following environment variable can be set to `true`
11
12```
13SILENT_ERROR=verbose <run program>
14```
15
16## Example
17
18```js
19// in one node module
20async function runCommand(name) {
21 // some logic
22 throw new SilentError(`command: '${name}' is not installed`);
23}
24```
25
26```js
27// in another node_module
28async function caller() {
29
30 try {
31 await runCommand('foo');
32 } catch(e) {
33 SilentError.debugOrThrow(e);
34 }
35
36 SilentError.debugOrThrow
37}
38```
39
40## Installation
41
42```
43yarn add silent-error
44```
45
46or
47
48```
49npm install --save silent-error
50```