public Mono<ChatRoom> getChatRoom(UUID id)
{
int shard = selectShard(id);
- if (chatHomes[shard] == null)
- throw new ShardNotOwnedException(shard);
- return chatHomes[shard].getChatRoom(id);
+ return chatHomes[shard] == null
+ ? Mono.error(new ShardNotOwnedException(shard))
+ : chatHomes[shard].getChatRoom(id);
}
@Override
{
if (loadInProgress)
{
- throw new LoadInProgressException();
+ return Mono.error(new LoadInProgressException());
}
if (!isShardOwned[shard])
{
- throw new ShardNotOwnedException(shard);
+ return Mono.error(new ShardNotOwnedException(shard));
}
return Mono.justOrEmpty(chatrooms[shard].get(id));