Error Dejection Operator

Thanks for those comments @jithujoshyjy - I'm starting to understand your inspiration better.

For now, I'm actually not going to make a proposal for this (if someone else wants to, feel free). Instead, I've recently proposed over on this thread that we make Javascript a little more expression-oriented by turning a handful of statements into expressions, including try-catch. The details about how each statement will get turned into an expression can be debated.

The proposal repo is here, and there's an issue on it here that discusses what would be the best way of providing an expression form of try-catch. It links to some different possible ideas that have been brought up in these forms, including this "|^" idea and the "const { value, error } = try whatever()" idea from the other thread. I assume only one will likely make it through, so it's just figuring out which would be the best fit.

1 Like