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

Streamline error handling #26

Open
MSch opened this issue Dec 5, 2011 · 1 comment
Open

Streamline error handling #26

MSch opened this issue Dec 5, 2011 · 1 comment

Comments

@MSch
Copy link

MSch commented Dec 5, 2011

It'd be nice to have some syntax extensions to streamline error handling according to node-convention.

I propose finding a better way to express

  var bcryptShortcut = function (data, autocb) {
    await bcrypt.gen_salt(defer(var err, salt));
    if (err)
      return err;
    await bcrypt.encrypt(data, salt, defer(var err, hash));
    if (err)
      return err;
    return undefined, hash;
  };

  await bcryptShortcut("B4c0/\/", defer(var err, encrypted));

For example:

  var bcryptShortcut = function (data, autocberr) {
    await bcrypt.gen_salt(defer(autoerr, var salt));
    await bcrypt.encrypt(data, salt, defer(autoerr, var hash));
    return hash;
  };

  await bcryptShortcut("B4c0/\/", defer(var err, encrypted));

What do you think? How hard would it be to implement this transformation?

@freewind
Copy link

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

2 participants