[Proposal] Allow rest parameter on try... catch

Michaël Rouges michael.rouges at gmail.com
Wed Jul 15 06:28:50 UTC 2020

Hi all,

My proposal's goal is really simple: provide a way to handle any numbers of
errors, at once, in a synced try... catch.

The problem:
async function reject (key) {
  throw new Error(`error with key: ${key}`)

async function test () {
  try {
    await Promise.all([...new Array(3).keys()].map(reject))
  } catch (error) {
    console.error(error) // Error: error with key: 0


Actually, we don't have a simple way to retrieve all errors in the catch
and it can be difficult to manage when we don't know how many errors we can

Then, IMHO, allowing the rest parameter on the `catch (...errors)` resolves
that problem, without breaking changes.

What do you think about it, please?

Michaël Rouges - https://github.com/Lcfvs - @Lcfvs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200715/796a4887/attachment.html>

More information about the es-discuss mailing list