Axel Rauschmayer
2014-10-09 12:23:54 UTC
Use case: With promises, the expression body form of arrow functions is so convenient. Alas, `throw` being a statement, you can?t use it there. For example, the following code is not syntactically legal:
```js
asyncFunc()
.then(count => count >= 0 ? count : throw new Error(...))
.then(...)
.catch(...);
```
Could `throw` be turned into an expression?
--
Dr. Axel Rauschmayer
axel at rauschma.de
rauschma.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141009/69c35bb5/attachment-0001.html>
```js
asyncFunc()
.then(count => count >= 0 ? count : throw new Error(...))
.then(...)
.catch(...);
```
Could `throw` be turned into an expression?
--
Dr. Axel Rauschmayer
axel at rauschma.de
rauschma.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141009/69c35bb5/attachment-0001.html>