Exceptions cannot be ignored, but return-codes can. Events that require immediate attention, such as an allocation failure, are typically thrown, so that the calling function has to respond, no matter what. With return-codes, if an important event arises and a return-code is passed to the calling function, the event can go unnoticed. However, if an exception was thrown, the calling function would have no choice but to either terminate the program, or handle the exception.
Khosravib wrote: |
---|
"Is it possible to resume the program when an exception is thrown or not?" |
Yes, so long as the exception is caught and handled appropriately.
Exceptions are useful. However, exceptions:
- ...are not suitable for critical points in code
- ...provoke stack winding and stack unwinding
- ...must be handled at all costs
- ...forcefully break the construction of objects (if an exception is thrown during object construction)
Wazzak