error.lineNumber is undefined on V8
catch (e) {
Logger.log('Failed at ' + e.fileName + ':' + e.lineNumber); // V8: "Failed at undefined:undefined"
}
Why it happens
fileName and lineNumber were non-standard Mozilla properties on Error. Rhino filled them in; V8 doesn't support them as properties or as new Error(message, fileName, lineNumber) arguments.
The fix: use stack
catch (e) {
console.error(e.stack || e);
}
The stack format differs between runtimes, so update any code that parses it:
Rhino: at Code:92 (innerFunction)
V8: Error: message
at innerFunction (Code:92:11)
at outerFunction (Code:97:5)
// first "file:line" from a V8 stack
var m = String(e.stack).match(/\(([^:()]+):(\d+):\d+\)/);
var where = m ? m[1] + ':' + m[2] : 'unknown';
Errors also appear with full stacks in Executions and Cloud Logging ("exceptionLogging": "STACKDRIVER" in appsscript.json).
How V8Shift handles it
Every .lineNumber / .fileName access is flagged as a warning on the checklist.