What do you see as the main problem this is solving?
The only benefit I can see is for catching default assignments, as there is no way of catching those at the moment.
// not possible to catch this -> vvvvvvvvvvvvvvvvvv β
function functionName(arg1, arg2 = functionMightThrow(arg1)) {
try {
} catch (err) {
// but I can access function arguments here β
}
}
try function functionName(arg1, arg2 = functionMightThrow(arg1)) {
...
} catch (err) {
// can catch `functionMightThrow` β
// but no access to function arguments β
}
I was thinking just about readabΓity. Did not think about catching default arguments. What a great point! it syntactically make sense, since arguments follows "try" keyword. I'm a bit afraid catch block without arguments would be a bit weak since developer would not be able to log them. But still could be usefull in some cases.
an async function never produces an exception, only a rejected promise - so the catch wouldn't have anything to catch. If it did implicitly await the rejected promise and catch it, it'd be weird to be able to use await in that catch block outside the body of the async function.