kevinbeaty / fs-promise

[DEPRECATED] Use mz or fs-extra^3 with Promise support
https://www.npmjs.com/package/fs-extra
MIT License
170 stars 13 forks source link

Errors are missing stack traces #19

Closed cobbweb closed 7 years ago

cobbweb commented 7 years ago

I'm not sure if this is a problem in fs-promise, or something deeper, or maybe I'm doing something wrong (probably the latter): but if a Promise.catch on a top level promise catches something from deeper inside, it's missing the stack trace.

Example code to reproduce:

const fsp = require('fs-promise');

function readFile() {
  return fsp.readFile('./doesntexist', 'utf-8');
}

function main() {
  return readFile();
}

main().catch(err => {
  console.error(err); // err has no stack trace
  console.error(err.stack) // doesn't contain stack trace, where did the error come from?
});

Would be nice to have that stack trace to figure out when things go wrong in a more complicated real-world example.

RyanZim commented 7 years ago

Sorry, in the case of an ENONT error, you don't get a stack trace; even from the native fs module: https://runkit.com/57ebc041d4a27f140028fd78/589a4ec2bad1e40014ab02c3