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

Add support async handlers #3696

Closed
maxcbc opened this issue Jul 19, 2018 · 4 comments
Closed

Add support async handlers #3696

maxcbc opened this issue Jul 19, 2018 · 4 comments

Comments

@maxcbc
Copy link

maxcbc commented Jul 19, 2018

Hi folks,

I had an idea to support catching errors in an async function without an 'unhandledPromiseRejectionError'.

This gives developers the freedom to throw again but also means they don't have to do the following pattern.

async function (req, res, next) {
  let result;
  try {
    result = await something();
  } catch (err) {
    next(err);
  }
  res.send(result);
}

They can instead do:

async function (req, res, next) {
  res.send(await something());
}

PR done as an idea: #3695

@dougwilson
Copy link
Contributor

We have some promise based ones and I think that would include async functions. Regardless we would love to see your idea! Thanks for opening an issue before making a PR because you may have accidentally made one against this repo on accident. Please make any router change PRs to the repo https://github.com/pillarjs/router and not this repo 👍

@maxcbc
Copy link
Author

maxcbc commented Jul 19, 2018

Thanks Doug. Will do.

@maxcbc
Copy link
Author

maxcbc commented Jul 19, 2018

@dougwilson Should I close this issue and re-raise on https://github.com/pillarjs/router ?

@dougwilson
Copy link
Contributor

Closing as issue + PR opened in router module.

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