ahmadnassri / node-metalsmith-pug

Metalsmith plugin to convert jade files
https://www.npmjs.com/package/metalsmith-pug
MIT License
21 stars 10 forks source link

Errors are not passed to metalsmith's done callback #61

Open AndyOGo opened 7 years ago

AndyOGo commented 7 years ago

I just realized, that if one file errors, because of wrong pug syntax like:

.correct

buggy*line/throws

This error is not properly handled and passed to done callback, instead it is just ignored...

It is very important to propagate the error so that one could handle it by:

metalsmith.build((err) => {
  if(err) {
    // handle it here
    return
  }
})

Refer to the docs about proper error handling in Node:

ahmadnassri commented 7 years ago

this is stemming from the Pug API lacking details on capturing errors: https://pugjs.org/api/reference.html

better error handling is certainly needed, will look into it.

AndyOGo commented 7 years ago

I see. I quickly checked pug's repo. They do not use error-first arguments. Instead they use good old throw. So my guess try, catch is the correct way to do it.

ahmadnassri commented 7 years ago

yep. happy to take PRs, otherwise will add to my backlog.

AndyOGo commented 7 years ago

sure, happy to help out