Do not cache if exception in Factory class

[Authenticate]
public class OrgYesterdaySnapshotService : Service
{
    public object Any(OrgYesterdaySnapshot request)
    {

        if (!request.Dt.HasValue)
            request.Dt = DateTime.Today;

        return base.Request.ToOptimizedResultUsingCache<OrgYesterdaySnapshot>(
             base.Cache, request.CacheKey, CacheExpiryTime.DailyLoad(), () =>
             {
                 return OrgYesterdaySnapshotFactory.GetObject(request, SessionAs<DVAuthUserSession>().UserName);
             });
    }
}

Sample service above. Wondering if there’s a common coding pattern to prevent putting an object in the cache if there was some type of Exception in the Factory class. We’re running into an issue where a temporal error (like a database timeout) causes an object to load incorrectly. In those instances, I don’t want to load the object into the cache (let the next caller re-run the factory and hopefully get a read object, which is then the one that hits the cache).

Throwing an exception in the cache function shouldn’t cache the result, are you seeing that it does?

Nevermind. I was catching the exception to log it, but not re-throwing it.

The lesson, as always, is that I’m an idiot.