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

capture-stack-trace

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capture-stack-trace

Error.captureStackTrace ponyfill

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2M
decreased by-18.06%
Maintainers
1
Weekly downloads
 
Created

What is capture-stack-trace?

The 'capture-stack-trace' npm package is a utility for capturing stack traces in Node.js. It is particularly useful for debugging and error handling, allowing developers to capture and manipulate stack traces programmatically.

What are capture-stack-trace's main functionalities?

Basic Stack Trace Capture

This feature allows you to capture the current stack trace and assign it to an object. The captured stack trace can then be logged or manipulated as needed.

const captureStackTrace = require('capture-stack-trace');

function myFunction() {
  const obj = {};
  captureStackTrace(obj);
  console.log(obj.stack);
}

myFunction();

Custom Error Stack Trace

This feature allows you to capture a stack trace for a custom error class. By passing the custom error class as the second argument, you can ensure that the stack trace starts from the point where the error was instantiated.

const captureStackTrace = require('capture-stack-trace');

class CustomError extends Error {
  constructor(message) {
    super(message);
    captureStackTrace(this, CustomError);
  }
}

try {
  throw new CustomError('Something went wrong!');
} catch (error) {
  console.log(error.stack);
}

Other packages similar to capture-stack-trace

Keywords

FAQs

Package last updated on 10 Oct 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