neat-errors
v1.0.8
Published
Provide beautiful and practical error messages for your command-line tools
Downloads
2
Maintainers
Readme
Neat Errors for NodeJs
This is a really neat error reporter for NodeJS, featuring code extraction, stack cleaning, syntax highlighting and tweakable output out-of-the-box.
Usage
Easiest way is to require neat-errors/register
at the top of your application entry point:
import "neat-errors/register";
// do your stuff here ...
If not possible in your case, then you can use the full programmatic API:
import Neat from "neat-errors"
const neat = new Neat()
process.on('uncaughtException', e => {
console.error(neat.render(e));
process.exit(1);
})
Unless specified manually, neat-errors
will check for the following options in
process.argv
and adapt its behaviour accodingly:
- --full-stack-trace: do not clean the stack trace before rendering
- --print-all-code print a code excerpt for all call sites in the stack trace
Other than that, the following arguments can be supplied to Neat
as an options object:
- cwd: current working directory to make paths relative to.
- printAllCode: defaults to checking
process.argv
for its value - fullStackTrace: defaults to checking
process.argv
for its value
Contributing
Suggestions? Found a bug? You are more than welcome to contribute! Please browse the current issues to check if someone else got to it first before submitting a new one.
Related projects
- pretty-error: does not print the source file
License
The MIT License