Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Created February 10, 2012 20:12
Show Gist options
  • Save jorendorff/1792391 to your computer and use it in GitHub Desktop.
Save jorendorff/1792391 to your computer and use it in GitHub Desktop.
// *** Design #1: helper class
if (AutoFinallyBlock afb(cx, ok)) {
bool closedOK = CLOSE THE ITERATOR;
ok = afb.leave(closedOK);
}
// *** Design #2: no helper class
if (ok || cx->isExceptionPending()) {
Value exc;
if (!ok) {
exc = cx->getPendingException();
cx->clearPendingException();
}
bool closedOK = CLOSE THE ITERATOR;
if (!ok && closedOK)
cx->setPendingException(exc);
ok = ok && closedOK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment