|
|
|
|
|
by spankalee
637 days ago
|
|
Since the proposal is moving to try expressions, my main criticism there is that I don't usually just want the error as a value, as then I still need to check it and write a branch to handle the error case. It's nice that I could use const on the value variable instead of let, but that's such a small gain. What I really want for the expression to return the value, but give a branch for the error case: // We still get a catch block to handle errors in
const value = try foo() catch (e) {
throw new MyError('Error trying to foo');
};
Otherwise we have to write this to handle the error: const [value, error] = try foo();
if (error) {
throw new MyError('Error trying to foo');
}
And it's far to easy to forget the error handling code altogether, resulting in silent failures.edit: removed a brain-fart on a case that's already handled by JS :O |
|