/** Destroys all destroyables in this bag and clears its contents.
* @throws MultiFailureException containing one or more exceptions if any destroyable throws an
* exception while being destroyed. {@code destroy} will always be called on all destroyables
* regardless of whether any throw an exception. */
public void clear () {
MultiFailureException mfe = null;
for (Destroyable dable : _dables) {
try {
dable.destroy();
} catch (Exception e) {
if (mfe == null) mfe = new MultiFailureException();
mfe.addFailure(e);
}
}
_dables.clear();
if (mfe != null) throw mfe;
}