Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
error-stack-parser
Advanced tools
The error-stack-parser package is a utility for parsing and extracting information from JavaScript Error stacks. It provides a structured way to interpret error stack strings, making it easier to programmatically analyze errors, log them in a more readable format, or display them in user interfaces. It's particularly useful in applications where understanding the context and source of an error is crucial for debugging or error handling.
Parsing Error Stacks
This feature allows you to parse the stack property of Error objects into a more structured format. Each element in the returned array represents a frame in the stack trace, with properties such as the function name, file name, line number, and column number. This makes it easier to analyze and display error information programmatically.
const ErrorStackParser = require('error-stack-parser');
const error = new Error('This is a test error');
const stackFrames = ErrorStackParser.parse(error);
console.log(stackFrames);
stacktrace-js provides similar functionality to error-stack-parser by offering mechanisms to capture, parse, and manipulate JavaScript stack traces. It goes a bit further by also allowing stack trace collection from all browsers and generating stack traces from thrown errors or caught exceptions. Compared to error-stack-parser, stacktrace-js might offer a broader set of features for handling stack traces across different environments.
source-map-support is a package that adds source map support to node.js (for converting compiled code locations to their original source locations). While not a direct alternative to error-stack-parser, it complements its functionality by allowing developers to obtain accurate stack traces in their original source code, not the transpiled or compiled version. This is especially useful in projects where code is bundled or transpiled.
Simple, cross-browser Error parser.
This library parses and extracts function names, URLs, line numbers, and column numbers from the given Error's stack
as
an Array of StackFrames.
Once you have parsed out StackFrames, you can do much more interesting things. See stacktrace-gps.
Note that in IE9 and earlier, Error
objects don't have enough information to extract much of anything. In IE 10, Error
s
are given a stack
once they're throw
n.
ErrorStackParser.parse(new Error('boom'));
=> [
StackFrame('funky1', [], 'path/to/file.js', 35, 79),
StackFrame('filter', undefined, 'https://cdn.somewherefast.com/utils.min.js', 1, 832),
StackFrame(... and so on ...)
]
npm install error-stack-parser
bower install error-stack-parser
https://raw.githubusercontent.com/stacktracejs/error-stack-parser/master/dist/error-stack-parser.min.js
Want to be listed as a Contributor? Start with the Contributing Guide!
v1.3.4
FAQs
Extract meaning from JS Errors
The npm package error-stack-parser receives a total of 8,087,462 weekly downloads. As such, error-stack-parser popularity was classified as popular.
We found that error-stack-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.