in knative-build/runtimes/javascript/utils/debug.js [140:180]
function _updateContext(callerFunctionLabel){
try{
let obj = {};
Error.stackTraceLimit = 2;
Error.captureStackTrace(obj, _updateContext);
let fullStackInfo = obj.stack.split(")\n");
let rawFunctionInfo = fullStackInfo[1];
let entryInfo = rawFunctionInfo.split("at ")[1];
// TODO: if there is no '(' separator, we have no function name; do not split
// e.g., value would look like: /openwhisk-knative-build/runtimes/javascript/src/service.js:180:19
if( entryInfo.indexOf(" (") !== -1) {
let fm = entryInfo.split(" (");
this.functionName = fm[0];
this.fullModuleInfo = fm[1];
} else {
// assume the entry has the full module name and path (function is a anonymous)
this.functionName = "anonymous";
this.fullModuleInfo = entryInfo;
}
if( typeof this.fullModuleInfo !== "undefined")
this.moduleInfo = this.fullModuleInfo.substring( this.fullModuleInfo.lastIndexOf("/") +1);
// if explicit label provided, use it over one from stack trace...
if(typeof(callerFunctionLabel) !== 'undefined') {
if( this.functionName === "anonymous")
this.functionName = callerFunctionLabel + "." + this.functionName;
else
this.functionName = callerFunctionLabel;
}
} catch(e){
console.error("Unable to parse stack trace: " + e.message);
}
}