4 ms·
So every function now needs a try/catch? Doesn't this kind of defeat the purpose?
by sausagefeet 15y ago
So every function now needs a try/catch? Doesn't this kind of defeat the purpose?
- daeken 15y agoEvery call to a function that can throw an exception should have a try/catch block, so that things can be properly cleaned up. Global exception handlers are seldom useful outside of reporting the existence of an error for future usage.
- sausagefeet 15y agoBut every function can potentially throw an exception...
- rwallace 15y agoIn that case, wouldn't it be simpler to explicitly check for error return on every call to such a function, and eliminate the need for an exception mechanism?
- norswap 15y agoKind of defeat the point of exceptions in the first place. It becomes more like an "enhance error return value" thing. The thing about an exception is that you can't do about it in a number of scopes. When you encounter the exception you just just jump to the scope where you can do something about it.