pretty-error

pretty-error (GitHub: AriaMinaei/pretty-error, License: MIT) is a module by Aria Minaei to render node.js error stack in a much more digestable way. This seems like it might a good module to add to your infrastracture if you, like me, constantly having to weed through the ugly stack messages to find relavant lines.

npm install pretty-error

Usage

require('pretty-error').start(function() {
  startTheApp();
});

How it Works

pretty-error turns error objects into something similar to an HTML document, and then uses the upcoming RenderKid to render the document using simple HTML/CSS-like commands for the console. This allows pretty-error to be themed using simple CSS-like declarations.

The cool bits

Shortening paths

You might want to substitute long paths with shorter, more readable aliases:

pe.alias('E:/open-source/theatrejs/scripts/js', '(Theare.js)');

// to remove the alias:
pe.removeAlias('E:/open-source/theatrejs/scripts/js');

// or:
pe.removeAllAliases();

Skipping packages

You might want to skip trace lines that belong to specific packages (chai, when, socket.io):

pe.skipPackage('chai', 'when', 'socket.io');

// to unskip:
pe.unskipPackage('socket.io');
pe.unskipAllPackages();

Skipping node files

// this will skip node.js, path.js, event.js, etc.
pe.skipNodeFiles();

// also:
pe.unskipNodeFiles();

Skipping paths

pe.skipPath('/home/dir/someFile.js');

// also:
pe.unskipPath('/home/dir/someFile.js');
pe.unskipAllPaths();