Why is it better to throw an exception rather than return an error code?
问题 Legacy error handling tends to follow the method that all functions return a code depending on success/failure. You would check this code and handle (if an error) appropriately. Modern programming languages however follow the exception model, where if something exceptional happens that cannot be handled properly an exception gets thrown - which keeps bubbling up until its handled. My question is why have we moved towards the exception model ? What are the reasons behind this? Why is it better