DEV Community

Discussion on: Stop Using Try-Catch: A Better Way to Handle Errors in JavaScript

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

This operator is a very long way from becoming part of the language, if it ever does. It's from a DRAFT proposal that hasn't even been accepted for consideration yet, let alone inclusion.

Collapse
 
qianl15 profile image
Qian Li

Thanks! When I first read it I thought some new feature just dropped, and then I saw your comment 😂 The repo actually says, "This proposal will change to try-expressions as its a more idiomatic apporach to this problem." And they're looking for someone to help rewrite it...

guess there'll still be a long way to go.

Collapse
 
bloodbaz2 profile image
Chris Walsh

Articles like this always seem to gloss over this point which is really annoying.

Collapse
 
raegen profile image
Nikola Pavlovic • Edited

Yeah and then there's the fact that, like all new ecmascript features preparing to land, it will be supported for years, by being transpiled into the fuckton of "try-catch layers" it's supposed to mitigate. For something that can be facilitated by a trivial utility function (well, a monad ideally), adding a new operator to the language is a completely deranged idea.
Not to mention that it would be quite confusing and typo-prone to have the actual token '?=' used in this way considering ??= already exists and is totally unrelated

Collapse
 
victor_gp profile image
Víctor González Prieto • Edited

Thanks for the heads up. 👍

Can you link the proposal? I can't find it... Or do you know the name they're giving this new operator?

Collapse
 
jonrandy profile image
Jon Randy 🎖️
Thread Thread
 
victor_gp profile image
Víctor González Prieto

Thank you!