Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AndyOGo opened this issue Feb 15, 2017 · 4 comments · May be fixed by #62
Open

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

AndyOGo opened this issue Feb 15, 2017 · 4 comments · May be fixed by #62

Comments

@AndyOGo
Copy link

AndyOGo commented Feb 15, 2017

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
Copy link
Owner

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
Copy link
Author

AndyOGo commented Feb 15, 2017

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
Copy link
Owner

ahmadnassri commented Feb 15, 2017 via email

@AndyOGo AndyOGo linked a pull request Feb 15, 2017 that will close this issue
@AndyOGo
Copy link
Author

AndyOGo commented Feb 15, 2017

sure, happy to help out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants