
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
error-callsites
Advanced tools
Yet another module for extracting callsites (a.k.a. stack-frames) from
Node.js Error objects.
npm install error-callsites
var callsites = require('error-callsites')
var err = new Error('foo')
var frames = callsites(err)
console.log('Error occurred on line', frames[0].getLineNumber())
The module exposes a single function which expects an Error object as
the first argument:
var frames = callsites(err)
More specifically, it expects an object on which Error.captureStackTrace(obj)
has been called, which is the case for Error objects. You can do it directly
yourself:
var obj = {}
Error.captureStackTrace(obj)
var frames = callsites(err)
The function returns an array of
v8 CallSite objects
-- one for each frame in the stack trace. CallSite objects provide accessor
methods for information on that frame. For example:
callsite.getThis() - returns the value of thiscallsite.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 functioncallsite.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 functioncallsite.getFileName() - if this function was defined in a script returns the name of the scriptcallsite.getLineNumber() - if this function was defined in a script returns the current line numbercallsite.getColumnNumber() - if this function was defined in a script returns the current column numbercallsite.getEvalOrigin() - if this function was created using a call to eval returns a CallSite object representing the location where eval was calledcallsite.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?See the link above for a complete list of the accessor methods. Some have been added in more recent versions of v8 and Node.js.
This package works by setting a custom Error.prepareStackTrace
property that transparently captures the structured stack trace that v8 passes
to this API, while also supporting other Node.js code in the process setting
its own Error.prepareStackTrace.
FAQs
Extract callsite objects from Error objects
The npm package error-callsites receives a total of 326,456 weekly downloads. As such, error-callsites popularity was classified as popular.
We found that error-callsites demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.