domenic at domenicdenicola.com (2014-06-20T19:53:25.577Z)
FWIW: some implementations (e.g. SpiderMonkey) has this approach for years,
using guards:
```js
try { throw 1; }
catch (e if (e instanceof TypeError)) { console.log(e); }
catch (e) { console.log('Generic handler:', e); }
```
On Tue, Jun 17, 2014 at 12:36 PM, C. Scott Ananian <ecmascript at cscott.net> wrote: > My guess would be that `catch` is reserved so that (in a future > version of JavaScript) this won't be ambiguous: > ``` > try { stuff(); } > catch(e1) { } > catch(e2) { } > ``` > > Currently JS only allows a single catch clause. FWIW: some implementations (e.g. SpiderMonkey) has this approach for years, using guards: try { throw 1; } catch (e if (e instanceof TypeError)) { console.log(e); } catch (e) { console.log('Generic handler:', e); } Dmitry > But if it ever grows > guarded catch expressions, then you would want to add multiple catch > clauses. All but the first could potentially be ambiguous with an > invocation of a function named `catch`. > --scott > _______________________________________________ > 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/20140617/b96b750a/attachment.html>