Skip to content

chrismwendt/pretty-error-tree

Repository files navigation

pretty-error-tree

Pretty-prints Node.js Error objects in a tree style.

  • Shows lines of source code
  • Flattens nested causes
  • Shortens file paths
  • Highlights function names
  • Colors the output
  • Filters out internal Node.js frames

pretty-error-tree output

Here's the default Node.js error output for comparison:

Default node error output

Installation

yarn add pretty-error-tree@chrismwendt/pretty-error-tree

Usage

Pretty-print an error:

import { prettyErrorTree } from 'chrismwendt/pretty-error-tree'

try {
  throw new Error('foo')
} catch (err) {
  console.log(prettyErrorTree(err))
}

Install a global handler for uncaught errors:

import { installPrettyErrorTree } from 'chrismwendt/pretty-error-tree'

installPrettyErrorTree() // Now all uncaught errors will be pretty-printed

throw new Error('foo') // This will be pretty-printed

About

Pretty prints Node.js errors in a tree

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors