Not quite. If the `else` (or `nocatch`, whatever) block throws, it would
bypass the `catch` block but still hit the `finally` block the same way
an exception in the `catch` block would:
* if `a` doesn't throw: a, b, d
* if `a` throws: a, c, d
* if `b` throws: a, b, d
* if `a` and `c` throw: a, c, d

This is analogous to this promise equivalent:

```
console.log("a");
a()
.then(() => {
    console.log("b");
    return b();
}, () => {
    console.log("c");
    return c();
})
.finally(() => {
    console.log("d");
})
```

(note the use of both arguments to `then`)

Your reading wouldn't really provide anything that can't be done by
simply moving the else block's content into the try block.
--
  Alan Plum
  m...@pluma.io



On Tue, Feb 13, 2018, at 12:54 PM, T.J. Crowder wrote:
> On Tue, Feb 13, 2018 at 11:30 AM, Isiah Meadows
> <isiahmead...@gmail.com> wrote:> >
> > If you did `else` before `catch`/`finally`, that'd solve your
> > problem. ;-)> >
> > The catch with `finally` (no pun intended) is this: does/should it
> > execute *before* or *after* else?
> 
> Logically it makes sense `finally` would be after, so putting the
> `else` after `try` and before `catch`/`finally` makes sense for that
> reason as well:> 
> ```js
> try {
>     console.log('a');
>     a();
> } else {
>     console.log('b');
>     b();
> } catch (e) {
>     console.log('c');
>     c();
> } finally {
>     console.log('d');
>     d();
> }
> ```
> 
> Then
> 
> * If `a` doesn't throw: a, b, d.
> * If `a` throws: a, c, d.
> * If `b` throws: a, b, c, d
> * If `a` and `c` both throw: a, c, d
> * If `b` and `c` both throw: a, b, c, d
> 
> `else` doesn't make sense in English terms anymore, though. `then`
> would though, and on first blush would be consistent with what the
> promise version of this would look like:> 
> ```js
> console.log("a");
> a()
> .then(() => {
>     console.log("b");
>     return b();
> })
> .catch(() => {
>     console.log("c");
>     return c();
> })
> .finally(() => {
>     console.log("d");
> })
> ```
> 
> -- T.J. Crowder

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to