Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | # clean-stack [![Build Status](https://travis-ci.org/sindresorhus/clean-stack.svg?branch=master)](https://travis-ci.org/sindresorhus/clean-stack)
|
---|
| 2 |
|
---|
| 3 | > Clean up error stack traces
|
---|
| 4 |
|
---|
| 5 | Removes the mostly unhelpful internal Node.js entries.
|
---|
| 6 |
|
---|
| 7 | Also works in Electron.
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | ## Install
|
---|
| 11 |
|
---|
| 12 | ```
|
---|
| 13 | $ npm install clean-stack
|
---|
| 14 | ```
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | ## Usage
|
---|
| 18 |
|
---|
| 19 | ```js
|
---|
| 20 | const cleanStack = require('clean-stack');
|
---|
| 21 |
|
---|
| 22 | const error = new Error('Missing unicorn');
|
---|
| 23 |
|
---|
| 24 | console.log(error.stack);
|
---|
| 25 | /*
|
---|
| 26 | Error: Missing unicorn
|
---|
| 27 | at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
|
---|
| 28 | at Module._compile (module.js:409:26)
|
---|
| 29 | at Object.Module._extensions..js (module.js:416:10)
|
---|
| 30 | at Module.load (module.js:343:32)
|
---|
| 31 | at Function.Module._load (module.js:300:12)
|
---|
| 32 | at Function.Module.runMain (module.js:441:10)
|
---|
| 33 | at startup (node.js:139:18)
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | console.log(cleanStack(error.stack));
|
---|
| 37 | /*
|
---|
| 38 | Error: Missing unicorn
|
---|
| 39 | at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
|
---|
| 40 | */
|
---|
| 41 | ```
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | ## API
|
---|
| 45 |
|
---|
| 46 | ### cleanStack(stack, [options])
|
---|
| 47 |
|
---|
| 48 | #### stack
|
---|
| 49 |
|
---|
| 50 | Type: `string`
|
---|
| 51 |
|
---|
| 52 | The `stack` property of an `Error`.
|
---|
| 53 |
|
---|
| 54 | #### options
|
---|
| 55 |
|
---|
| 56 | Type: `Object`
|
---|
| 57 |
|
---|
| 58 | ##### pretty
|
---|
| 59 |
|
---|
| 60 | Type: `boolean`<br>
|
---|
| 61 | Default: `false`
|
---|
| 62 |
|
---|
| 63 | Prettify the file paths in the stack:
|
---|
| 64 |
|
---|
| 65 | `/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15` → `~/dev/clean-stack/unicorn.js:2:15`
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | ## Related
|
---|
| 69 |
|
---|
| 70 | - [extrack-stack](https://github.com/sindresorhus/extract-stack) - Extract the actual stack of an error
|
---|
| 71 | - [stack-utils](https://github.com/tapjs/stack-utils) - Captures and cleans stack traces
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | ## License
|
---|
| 75 |
|
---|
| 76 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.