Currently, when attempting to perform a Raft operation on a non-leader node, the following exception is thrown:
System.InvalidOperationException: The local cluster member is not a leader
---> System.OperationCanceledException: The operation was canceled.
Problem:
InvalidOperationException is too generic for this scenario and makes it difficult to distinguish between general invalid operations and leadership-related errors.
Suggestion:
Introduce a more specific exception type (e.g., NotALeaderException, LeaderUnavailableException, or similar) to clearly signal that the operation failed because the current node is not the Raft cluster leader.
Rationale:
Improves error handling for client applications.
Makes it easier to implement leader redirection or retry logic.
Better reflects the semantics of Raft operations.
Stack trace (for reference):
System.InvalidOperationException: The local cluster member is not a leader
---> System.OperationCanceledException: The operation was canceled.
at DotNext.Result`1.get_Value() in /_/src/DotNext/Result.cs:line 177
...
at DotNext.Net.Cluster.Consensus.Raft.RaftCluster`1.ReplicateAsync[TEntry](TEntry entry, CancellationToken token)