Why does RamdomSampler enforce num sample >0?

I have a use case where dataset length can be zero. I was just hoping that Dataloader will provide no batch with dataset length zero but instead I get below error during Dataloader initialization.

ValueError: num_samples should be a positive integer value, but got num_samples=0

Just to experiment, I modified the RandomSampler to not raise ValueError for dataset length zero and it seems to work fine (i.e. as expected Dataloader does not provide any batch).

So my question is why does RandomSampler enforce num sample >0?