3 ms·
With exceptions, I can trivially pass error information through my whole call stack without any manual work and boilerplate. The whole syntax clutter / OMG-but-
by _pmf_ 9y ago
With exceptions, I can trivially pass error information through my whole call stack without any manual work and boilerplate. The whole syntax clutter / OMG-but-try-catch-is-so-ugly is a very stupid argument: with exceptions, you can opt out of local error handling and opt-in at a higher level in the call stack without losing any information. With return code / error codes, this is just not possible. So exceptions declutter application code to a high degree.
Exceptions are to error codes as functions are to goto: there are valid cases where you want to prefer the latter, but they are few and far between.
- AstralStorm 9y agoIt is possible with global or contextual error state. This approach is used in iostream for example, and in a broken way in C library via errno. (Which does not work unless you check it very near.) Similar approach is often used in databases and file systems, marking an object as dirty or broken. Like the above, it is prone to ignoring errors and attempting to manipulate such object.