3 ms·
But what is your alternative? Doesn't checking the return code of every statement also make a tremendous amount of visual noise? I've seen C code where about 8
by wladimir 15y ago
But what is your alternative? Doesn't checking the return code of every statement also make a tremendous amount of visual noise?
I've seen C code where about 80% of the code is dedicated to error handling and corner cases. Before every statement it has to check the current error status, and after it the return value... it's almost unreadable.
With try/except/finally a lot of that can be cleaned up, by handling the errors higher-up in the call hierarchy where they make sense to handle.
I see a lot of critique of exceptions, but haven't seen one better alternative yet, at least one that doesn't require switching to an obscure programming language.
Edit: this does assume that exceptions are used properly: for errors that should bubble up, not as extra return value.