Proposal: Conditional `catch` in Promises

Isiah Meadows isiahmeadows at gmail.com
Wed Apr 25 15:31:17 UTC 2018


I'd still prefer we wait until pattern matching [1] gets addressed first,
then tackling this. Error types are represented about 50 different ways in
JS, with subtyping only being one (used by the standard kind of). Node
appends an `err.code`, and the DOM adds a similar type, just using a common
error subclass. And in some cases where errors are planned (but exceptions
are more convenient), you sometimes see non-errors thrown. So there needs
to be a means of catching all of them, and `if` checks get verbose and
noisy in a hurry.

On Wed, Apr 25, 2018, 00:11 Ayush Gupta <ayushg3112 at gmail.com> wrote:

> We could potentially provide the same functionality in `try/catch` by
> extending the signature of `catch` to
>
> ```js
> try {
>
> } catch(<expression_var>, <function_expression>) {
>
> }
> ```
>
> If `<function_expression>` evaluates to truthy, invoke the `catch` block,
> otherwise don't.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180425/c227f242/attachment.html>


More information about the es-discuss mailing list