livingcss
livingcss copied to clipboard
File creation errors not propogated
From: lib/generate.js
The following code uses CPS-style but it's within a promise chain.
The errors thrown are inside callbacks, hence they will never be returned up the promise chain.
mkdirp(path.dirname(dest), function(err) {
if (err) {
// this has no effect on the promise chain, since it's inside a callback
throw err;
}
fs.writeFile(dest, html, 'utf8', function(err) {
if (err) {
// this has no effect on the promise chain, since it's inside a callback
throw err;
}
});
});
Also, the following handling at the end will log errors from the promise chain, but will not allow them to propogate:
.catch(function(err) {
if (err) {
console.error(err.stack);
}
});