callsite-record
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -19,2 +19,11 @@ var fs = require('fs'); | ||
// Utils | ||
function parseStack (error) { | ||
try { | ||
return stackParser.parse(error); | ||
} | ||
catch (err) { | ||
return null; | ||
} | ||
} | ||
function getFrameTypeName (frame) { | ||
@@ -253,18 +262,20 @@ // NOTE: this throws in node 10 for non-methods | ||
CallsiteRecord.fromError = function (error, isCallsiteFrame) { | ||
var stackFrames = stackParser.parse(error); | ||
var stackFrames = parseStack(error); | ||
if (typeof isCallsiteFrame === 'function') { | ||
while (stackFrames.length) { | ||
if (!isCallsiteFrame(stackFrames[0])) | ||
if (stackFrames) { | ||
if (typeof isCallsiteFrame === 'function') { | ||
while (stackFrames.length) { | ||
if (isCallsiteFrame(stackFrames[0])) | ||
break; | ||
stackFrames.shift(); | ||
else | ||
break; | ||
} | ||
} | ||
} | ||
if (stackFrames.length) { | ||
var filename = stackFrames[0].getFileName(); | ||
var lineNum = stackFrames[0].getLineNumber() - 1; | ||
if (stackFrames.length) { | ||
var filename = stackFrames[0].getFileName(); | ||
var lineNum = stackFrames[0].getLineNumber() - 1; | ||
return new CallsiteRecord(filename, lineNum, 0, stackFrames); | ||
return filename && !isNaN(lineNum) ? new CallsiteRecord(filename, lineNum, 0, stackFrames) : null; | ||
} | ||
} | ||
@@ -271,0 +282,0 @@ |
{ | ||
"name": "callsite-record", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Create fancy log entries for errors and function call sites.", | ||
@@ -10,3 +10,5 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"test": "eslint lib test && mocha" | ||
"test": "eslint lib test && mocha", | ||
"publish-please": "publish-please", | ||
"prepublish": "publish-please guard" | ||
}, | ||
@@ -34,3 +36,4 @@ "repository": { | ||
"eslint": "^1.10.3", | ||
"mocha": "^2.4.5" | ||
"mocha": "^2.4.5", | ||
"publish-please": "^2.2.0" | ||
}, | ||
@@ -37,0 +40,0 @@ "dependencies": { |
@@ -0,0 +0,0 @@ # callsite-record |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
311
19261
3