Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

error-stack2

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-stack2

Parse and manipulate error.stack

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
decreased by-29.24%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage

error-stack

Parse and manipulate error.stack

Install

$ npm i error-stack

Usage

const parse = require('error-stack')
const {stack} = new Error('foo')

console.log(stack)
// Error: foo
//     at repl:1:11
//     at Script.runInThisContext (vm.js:123:20)

const parsed = parse(stack)

parsed.type // Error

parsed.message  // foo

parsed.traces
// [
//   {
//     callee: undefined,
//     source: 'repl',
//     line: 1,
//     col: 11
//   },
//   {
//     callee: 'Script.runInThisContext',
//     source: 'vm.js',
//     line: 123,
//     col: 20
//   }
// ]

parsed
.filter(({callee}) => !!callee)
.format()
// Error: foo
//     at Script.runInThisContext (vm.js:123:20)

parsed.type string

Error type

parsed.message string

The message used by Error constructor

parsed.traces Array<Trace>

interface Source {
  // The source of the the callee
  source: string
  line?: number
  col?: number
}

interface Trace extends Source{
  callee: string
  // Whether the callee is 'eval'
  eval?: boolean
  // The source location inside eval content
  evalTrace: Source
}

parsed.filter(filterFunction): this

  • filterFunction Function the same as the callback function of Array.prototype.filter(callback)

Filters the current traces

parsed.format(): string

Format object parsed

License

MIT

Keywords

FAQs

Package last updated on 02 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc