@koddsson/errorstacks
TypeScript icon, indicating that this package has built-in type declarations

2.4.1 • Public • Published

errorstacks

Simple parser for Error stack traces.

Currently supported browsers/platforms:

  • Firefox
  • Chrome
  • Edge
  • Node

Usage

Install errorstacks via your package manager of choice. Here we'll use npm.

npm install errorstacks

Example code:

import { parseStackTrace } from 'errorstacks';

function foo() {
  throw new Error('fail');
}

try {
  foo();
} catch (err) {
  const parsed = parseStackTrace(err.stack);
  console.log(parsed);
  // Logs:
  // [
  //   {
  //     line: 4,
  //     column: 8,
  //     type: '',
  //     name: 'foo',
  //     raw: '    at foo (/my-project/foo.ts:4:8)'
  //   },
  // ]

Note: type will be the string "native" if native code execution was detected.

License

MIT, see the license file

Readme

Keywords

none

Package Sidebar

Install

npm i @koddsson/errorstacks

Weekly Downloads

2

Version

2.4.1

License

MIT

Unpacked Size

31.9 kB

Total Files

14

Last publish

Collaborators

  • koddsson