Socket
Socket
Sign inDemoInstall

error-callsites

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    error-callsites

Extract callsite objects from Error objects


Version published
Weekly downloads
232K
decreased by-32.03%
Maintainers
1
Install size
7.75 kB
Created
Weekly downloads
 

Readme

Source

error-callsites

Yet another module for extracting callsites (a.k.a. stack-frames) from Node.js Error objects.

Build status js-standard-style

Installation

npm install error-callsites

Usage

var callsites = require('error-callsites')

var err = new Error('foo')
var stack = callsites(err)

console.log('Error occurred on line', stack[0].getLineNumber())

API

The module exposes a single function which expects an Error object as the first arguemnt:

var arr = callsites(err)

The function returns an array of callsite objects - one for each frame in the stack trace.

Callsite object

Each element in the returned array is a V8 callsite object and in turn reponds to the following V8 functions:

  • callsite.getThis() - returns the value of this
  • callsite.getTypeName() - returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property.
  • callsite.getFunction() - returns the current function
  • callsite.getFunctionName() - returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
  • callsite.getMethodName() - returns the name of the property of this or one of its prototypes that holds the current function
  • callsite.getFileName() - if this function was defined in a script returns the name of the script
  • callsite.getLineNumber() - if this function was defined in a script returns the current line number
  • callsite.getColumnNumber() - if this function was defined in a script returns the current column number
  • callsite.getEvalOrigin() - if this function was created using a call to eval returns a CallSite object representing the location where eval was called
  • callsite.isToplevel() - is this a toplevel invocation, that is, is this the global object?
  • callsite.isEval() - does this call take place in code defined by a call to eval?
  • callsite.isNative() - is this call in native V8 code?
  • callsite.isConstructor() - is this a constructor call?

License

MIT

Keywords

FAQs

Last updated on 27 Oct 2016

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