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

File creation errors not propogated #83

Open
matmar10 opened this issue Apr 5, 2020 · 0 comments
Open

File creation errors not propogated #83

matmar10 opened this issue Apr 5, 2020 · 0 comments

Comments

@matmar10
Copy link

matmar10 commented Apr 5, 2020

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);
      }
    });
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

No branches or pull requests

1 participant