4 ms·
> Error handling is very painful Wait until you try Typescript. First you have to try/catch and then you also need an if statement to type assert the error in
by randomdata 4y ago
> Error handling is very painful
Wait until you try Typescript. First you have to try/catch and then you also need an if statement to type assert the error in order to do anything with it. Now that's painful. If errors were commonly returned as values you could beautifully reduce it to if statements alone.
- mekster 4y agoIf the called function only returns a specific type, how is there a need to type check the returning value?
- randomdata 4y agoThrown errors are always of type unknown, so you have to assert them back into a known type. Or throw caution to the wind and arbitrarily cast them to a type of your choosing, but that never ends well. A robust and maintainable system can’t reasonably do that.