Socket
Socket
Sign inDemoInstall

stacktrace-parser-node

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stacktrace-parser-node

Stacktrace parser for NodeJS written in Typescript with getting the code in which the error occurs.


Version published
Weekly downloads
43
increased by16.22%
Maintainers
1
Install size
26.7 kB
Created
Weekly downloads
 

Readme

Source

Stacktrace Parser

Stacktrace parser for NodeJS written in Typescript with getting the code in which the error occurs.

Installation

# Using npm
npm install --save stacktrace-parser-node

# Using yarn
yarn add stacktrace-parser-node

Usage

import { stacktrace } from "stacktrace-parser-node";

try {
  throw new Error();
} catch(error: Error) {
  const stack = stacktrace.parse(error);
  //handle stack
}

Response

Basic

FieldTypeDescription
messagestringError description from Error
namestringError name from Error
tracesTrace[]List of traces

Trace object

FieldTypeDescription
filenamestringThe name of the file in which the error occurs
functionstringThe name of the function where the error occurred
lineNonumberLine number with error
columnNonumberColumn number with error
internalbooleanA flag that determines whether the error has occurred in our code or in the code from installed packages
absPathstringAbsolute path to the file where the error occurs
extensionstringExtension of the file where the error occurs
codestring[]Line of code where the error occurs
preCodestring[]5 lines of code before code
postCodestring[]5 lines of code after code

Example JSON

{
    "name": "QueryFailedError",
    "message": "missing FROM-clause entry for table \"accountapplica\"",
    "traces": [
        {
            "filename": "PostgresQueryRunner.js",
            "function": "PostgresQueryRunner.query",
            "absPath": "C:\\Users\\user\\Desktop\\project\\node_modules\\typeorm\\driver\\postgres\\PostgresQueryRunner.js",
            "lineNo": 211,
            "columnNo": 19,
            "internal": false,
            "extension": "js",
            "code": "            throw new QueryFailedError_1.QueryFailedError(query, parameters, err);",
            "postCode": [
                "    }",
                "    /**",
                "     * Returns raw data stream.",
                "     */",
                "    async stream(query, parameters, onEnd, onError) {"
            ],
            "preCode": [
                "            }",
                "            return result;",
                "        }",
                "        catch (err) {",
                "            this.driver.connection.logger.logQueryError(err, query, parameters, this);"
            ]
        },
    ]
}

LICENSE

The MIT License (MIT)

Keywords

FAQs

Last updated on 14 Aug 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc