1 | # silent-error [![Build Status](https://travis-ci.org/ember-cli/silent-error.svg)](https://travis-ci.org/ember-cli/silent-error)
|
2 |
|
3 | 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.
|
4 |
|
5 | Some use-cases:
|
6 |
|
7 | * command in your CLI tool is missing
|
8 | * plugin to your build system is given invalid user-input.
|
9 |
|
10 | Obviously stack traces can still be valuable. To view the stacks, the following environment variable can be set to `true`
|
11 |
|
12 | ```
|
13 | SILENT_ERROR=verbose <run program>
|
14 | ```
|
15 |
|
16 | ## Example
|
17 |
|
18 | ```js
|
19 | // in one node module
|
20 | async 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
|
28 | async 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 | ```
|
43 | yarn add silent-error
|
44 | ```
|
45 |
|
46 | or
|
47 |
|
48 | ```
|
49 | npm install --save silent-error
|
50 | ```
|