JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 487
  • Score
    100M100P100Q86546F
  • License ISC

Make a color-coded stack trace from an error

Package Exports

  • neat-stack

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (neat-stack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

neat-stack

npm version Build Status Coverage Status

Make a color-coded stack trace from an error

const neatStack = require('neat-stack');
const request = require('request');

request('foo', err => console.error(neatStack(err)));
example

Useful for CLI applications — stack traces are not very important for end users but needed for authors to receive meaningful bug reports.

Installation

Use npm.

npm install neat-stack

API

const neatStack = require('neat-stack');

neatStack(error)

error: Error
Return: string

It returns a refined Error#stack:

const error = new Error('Hi');

error.stack; /* => `Error: Hi
    at Object.<anonymous> (/Users/example/run.js:1:75)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)` */

neatStack(error); /* => `\u001b[31mError: Hi\u001b[2m
    at Object.<anonymous> (~/example/run.js:1:88)\u001b[22m\u001b[39m` */

License

ISC License © 2017 - 2018 Shinnosuke Watanabe