Basic memoize with error count incrementation