1
try{
    cause error  
}
catch(err){  
    console.log(err.lineNumber) //or console.log(err.line)
}

The error object supports multiple things such as err.name, err.stack, and err.message but I can't find anything that works for logging the line of the error and filename. For example the stack actually shows the information I want that being "loader.js:13:22" but it's also the full stack. I'm sorry if this isn't a question I should be asking here but I've tried many "solutions" that haven't worked. Thank you in advance.

EDIT: Used this package https://www.npmjs.com/package/stack-trace supports everything I could ever need, thanks all.

Justin
  • 33
  • 4
  • Take a look at this, I think that's a similar question https://stackoverflow.com/questions/44200503/how-to-get-line-and-file-name-from-error-in-node-js – Shaharin Ahmed Jan 31 '21 at 08:27

1 Answers1

0

I think u will get the solution here link

Sebin
  • 64
  • 11