| ▲ | adontz 2 years ago | |||||||||||||||||||||||||||||||||||||
Honestly, this is so much worse than "catch". It's what a "catch" would look like in "C". | ||||||||||||||||||||||||||||||||||||||
| ▲ | hambes 2 years ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||
It might look worse than catch, but it's much more predictable and less goto-y. | ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
| ▲ | kbolino 2 years ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||
The biggest difference between try-catch and error values syntactically IMO is that the former allows you to handle a specific type of error from an unspecified place and the latter allows you to handle an unspecified type of error from a specific place. So the type checking is more cumbersome with error values whereas enclosing every individual source of exceptions in its own try-catch block is more cumbersome than error values. You usually don't do that, but you usually don't type-check error values either. | ||||||||||||||||||||||||||||||||||||||