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