Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,25 @@ function log (message, site) {
*/

function callSiteLocation (callSite) {
var file = callSite.getFileName() || '<anonymous>'
var line = callSite.getLineNumber()
var colm = callSite.getColumnNumber()

if (callSite.isEval()) {
file = callSite.getEvalOrigin() + ', ' + file
var functionName, site
if (callSite) {
functionName = callSite.getFunctionName()
var file = callSite.getFileName() || '<anonymous>'
var line = callSite.getLineNumber()
var colm = callSite.getColumnNumber()
if (callSite.isEval()) {
file = callSite.getEvalOrigin() + ', ' + file
}
site = [file, line, colm]
} else {
// eslint-disable-next-line no-param-reassign
callSite = {}
callSite.getThis = function () { return null }
functionName = '<unknown function>'
site = ['<unknown file>', '<unknown line>', '<unknown column>']
}

var site = [file, line, colm]

site.callSite = callSite
site.name = callSite.getFunctionName()

site.name = functionName
return site
}

Expand Down Expand Up @@ -389,6 +395,12 @@ function getStack () {
// capture the stack
Error.captureStackTrace(obj)

if (typeof obj.stack === 'string' || obj.stack instanceof String) {
// Means that prepareObjectStackTrace failed, obj.stack is not a CallSite array.
// We fallback to returning an empty array.
return []
}

// slice this function off the top
var stack = obj.stack.slice(1)

Expand Down