Memoize errors

Now errors do not prevent memoization. If the method is called with the
same arguments, the same Exception object is raised without an
additional call to the method.