error lineNumber and filename
- Node.js Version: 6.10.2
- OS: windows 10
I'm not able to track error lineNumber and fileName using error.lineName or error.fileName ??
Can you give more context? An example of what you’re trying to do or what doesn’t work?
I'm trying to log error lineNumber and fileName in a file using error.lineNumber and error.fileName but it is showing undefined for linenumber and filename. But it is showing result for error name and code using error.name and error.code. I want same for error lineNumber and fileName. Kindly help me through this.
On Thu, Jul 27, 2017 at 8:15 PM, Anna Henningsen [email protected] wrote:
Can you give more context? An example of what you’re trying to do or what doesn’t work?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/756#issuecomment-318383951, or mute the thread https://github.com/notifications/unsubscribe-auth/AISs-Vx9oimhk75mHKJpeucofGbfvAU7ks5sSKKDgaJpZM4OlYkz .
They're non-standard properties. More specifically, they are Mozilla extensions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber
You can try to parse the error stack (err.stack) which usually contains file names and line numbers, but this is kind of hacky.
https://github.com/v8/v8/wiki/Stack-Trace-API is a better alternative to parsing the stringified stack trace, fwiw. Maybe that helps.
closing as answered, please let me know if that is not the case.