Ignore the error.
The destructor may “fail” if, for example, the class wraps some kind of output, and the destructor resets and closes this output. Data recording may fail. Then your parameters should interrupt the program, or catch an exception, ignore the error and return. Usually the right design should ignore it.
"close_and_flush", , , . , , , .
:
{
OutputObject OO;
write some stuff to OO, might throw;
do more things, might throw;
try {
OO.flush_and_close();
} catch (OutputException &e) {
log what went wrong;
maybe rethrow;
}
}
:
try {
OutputObject OO;
write some stuff to OO, might throw;
do more things, might throw;
OO.flush_and_close();
} catch (AnyOldException &e) {
log what went wrong;
maybe rethrow;
}
, , , - , . , , - , .