jashkenas/coffee-script — Issue #1763: Enhanced catch
Author: axnsoftware
Created: 2011-10-10 20:46:54+00:00
State: open

Please extend the language by introduction of an extended catch statement.

Proposal:

try
do foo, bar
catch e, []
# ...
catch e, MyError
# ...
catch e

which would be compiled to

try {
do(foo, bar);
}
catch e if e instanceof or e instanceof or ... e instanceof {
// ...
}
catch e if e instanceof MyError {
// ...
}
catch e {
// ...
}

Yes, I know that you can already use catch e if e ... but look at the savings for the default usecase.

Of course the old notation, i.e. catch e if ... will still be available.

TIA and keep up the great work!