Api: use Throwable rather than Exception as the catch-all

Things like StackOverflowError are Throwable > Error, not Throwable >
Exception, so we were missing them.
SubQueryPlan: avoid infinite recursion

Do not revisit an object for which you have already updated the read-write set.
May happen in case of recursion.
Merge pull request #603 from uwescience/fix-599

Fix #599