Streamline error handling #26

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

Projects

None yet

2 participants

@MSch
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment