rocjs / roc

🐦 Modern JavaScript Development Ecosystem
MIT License
425 stars 23 forks source link

Roc logging doesn't work in verbose mode if `error.stack` is falsy #197

Open Alxandr opened 6 years ago

Alxandr commented 6 years ago

I had a library give me errors that had error.stack set to false, which roc just logs as false (instead of the error message). See:

image

This is not very helpful as the error message is lost, and I have to step through roc code to figure out what went wrong.

The offending piece of code can be found here and here. I suggest adding a check (in addition to whether or not verbose logging is enabled) to see if error.stack is truthy. Something like this:

return `\n\n${getContext().verbose && error.stack ? error.stack : error.toString().replace(/^Error: /, '')}`;