silent-error ![Build Status](https://camo.githubusercontent.com/0d8509d54a26701a8bb424eaf50e7fc98b5c9ddf2b5599cad62ffd9e493fe0ef/68747470733a2f2f7472617669732d63692e6f72672f656d6265722d636c692f73696c656e742d6572726f722e737667)
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 <run program>
Example
// in one node module
async function runCommand(name) {
// some logic
throw new SilentError(`command: '${name}' is not installed`);
}
// 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