When SqlTopicRepository,Load() can't find a Topic, it throws a TopicNotFoundException. When CachedTopicRepository.Load() can't find a topic, it returns null. In fact, the signature for Load() on SqlTopicRepository returns a Topic, whereas the signature for Load() on CachedTopicRepository (and, incidentally, ITopicRepository) returns a Topic?.
There are good arguments for returning null vs. throwing an exception here. But the behavior and the return type nullability should be consistent—or, at least, clearly documented. That said, updating this behavior is a breaking change, and so this may need to wait until OnTopic 6.0.0.
When
SqlTopicRepository,Load()can't find aTopic, it throws aTopicNotFoundException. WhenCachedTopicRepository.Load()can't find a topic, it returnsnull. In fact, the signature forLoad()onSqlTopicRepositoryreturns aTopic, whereas the signature forLoad()onCachedTopicRepository(and, incidentally,ITopicRepository) returns aTopic?.There are good arguments for returning
nullvs. throwing an exception here. But the behavior and the return type nullability should be consistent—or, at least, clearly documented. That said, updating this behavior is a breaking change, and so this may need to wait until OnTopic 6.0.0.