Bad cleaning logic
Throwing the cleanup code from the destructor. This is doubly bad, because a.) Throwing from the destructor is usually bad and b.) Because even if you can catch it, there is nothing to be done.
File::~File() { if (!close(fd_)) { throw FileIOException("Could not close descriptor.", fd_); } }
User interface from hell
try { // ... lots of UI logic here ... } catch (Exception error) { alert("This program has performed an illegal operation and needs to quit."); System.exit(-1); }
Retry without refund
bool has_connected = false; while (!has_connected) { try { EstablishConnection(); has_connected = true; } catch (...) {
source share