1. errorstacks
Parse error stack traces
errorstacks
Package: errorstacks
Created by: marvinhagemeister
Last modified: Wed, 08 Nov 2023 23:03:23 GMT
Version: 2.4.1
License: MIT
Downloads: 219,058
Repository: https://github.com/marvinhagemeister/errorstacks

Install

npm install errorstacks
yarn add errorstacks

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code