Exceptions are approximately 10,000x slower than returning a status / error code depending on the programming language. This is because all stack data is tracked. This is bad.
In general, you will never have to use exceptions. In fact, at some point, the only thing that existed was the return codes.
The good thing about exceptions is that they will not allow the program to continue working if they are not processed correctly. Instead, the program crashes.
So, basically, if you forget about the processing of status messages or worry that others might not check return codes from your functions, exceptions stop the program and force it to fix. Although, I saw how many inexperienced programmers catch exceptions, do nothing with it, and then continue. This is basically the same as ignoring the return code from a function.
Another nice thing about exceptions is that they βbubbleβ automatically. Instead of passing error codes through a long chain of functions, you can set up your try catch at the highest level and handle any error accordingly (assuming you don't want anything else going on between them). For example, if something goes wrong, display the error page.
source share