![]() |
[C++] Structured Exception Handling
Do you use it? In what type of applications? Is it ever acceptable to mix EH and non EH code?
|
don't use it, but don't code often in C++ DID find a neat trick thought....
catch(...){ } is valid, WITH the ...'s. :D it's a catch-all. laughed my ass off reading that in an intro to C++ book :D |
Quote:
i.e. Quote:
Quote:
|
Whoa!
catch(...) is one of the worst things to write. Think of it this way. You're writing a device driver. You've got a catch(...) to handle everything. In the device driver, you somehow manage to access memory you shouldn't. Maybe you buffer overwrite, maybe you overread due to a bad format string, who knows? Now the catch(...) catches the AV. How the hell have you helped anyone? They should have AV'd but instead you keep running even though the driver is completely shot and unlikely to work properly from here on in. |
That's a good point, but my opinion is that letting an unhandled exception fall through serves no purpose whatsoever. The system doesn't tell you where that unhandled expection occured, either in the error box (Windows), or the core dump (UNIX/Linux), or that it was even an unhandled exception that caused the program to crash in the first place. If anything, you can always just do the following:
Quote:
In the end, I guess it's up to the developer to make the decision, but experience has taught me that unhandled exceptions that fall through can be a headache to debug. And ideally, a well written piece of code should have a catch() for all thrown exceptions, but this method handles the 'just in case". |
All times are GMT -8. The time now is 10:53 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project