pub enum RabiaError {
Show 16 variants
Network {
message: String,
},
Persistence {
message: String,
},
StateMachine {
message: String,
},
Consensus {
message: String,
},
NodeNotFound {
node_id: NodeId,
},
PhaseNotFound {
phase_id: PhaseId,
},
BatchNotFound {
batch_id: BatchId,
},
InvalidStateTransition {
from: String,
to: String,
},
QuorumNotAvailable {
current: usize,
required: usize,
},
ChecksumMismatch {
expected: u32,
actual: u32,
},
StateCorruption {
details: String,
},
PartialWrite {
details: String,
},
Timeout {
operation: String,
},
Serialization(Error),
Io(Error),
Internal {
message: String,
},
}Expand description
Error types that can occur during Rabia consensus operations.
This enum covers all possible error conditions that can arise during consensus protocol execution, from network failures to state corruption. Each error includes context information to aid in debugging and recovery.
§Error Categories
- Network Errors: Communication failures between nodes
- Persistence Errors: Storage and retrieval failures
- State Machine Errors: Application-level execution failures
- Consensus Errors: Protocol-level violations or failures
- Resource Errors: Missing nodes, phases, or batches
- Integrity Errors: Checksum mismatches and corruption
- Timeout Errors: Operations that exceed time limits
§Examples
use rabia_core::RabiaError;
let error = RabiaError::network("Connection refused");
if error.is_retryable() {
println!("This error can be retried");
}Variants§
Network
Network communication failure between nodes
Persistence
Persistent storage operation failure
StateMachine
State machine execution failure
Consensus
Consensus protocol violation or failure
NodeNotFound
Referenced node was not found in the cluster
PhaseNotFound
Referenced consensus phase was not found
BatchNotFound
Referenced command batch was not found
InvalidStateTransition
Invalid state machine transition attempted
QuorumNotAvailable
Insufficient nodes available to form a quorum
ChecksumMismatch
Data integrity check failed due to checksum mismatch
StateCorruption
State corruption detected in persistent storage
PartialWrite
Incomplete write operation detected
Timeout
Operation exceeded its timeout limit
Serialization(Error)
JSON serialization/deserialization failure
Io(Error)
File system or network I/O failure
Internal
Unexpected internal error
Implementations§
Source§impl RabiaError
impl RabiaError
Sourcepub fn network(message: impl Into<String>) -> Self
pub fn network(message: impl Into<String>) -> Self
Creates a new network error with the given message.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::network("Connection timeout");Sourcepub fn persistence(message: impl Into<String>) -> Self
pub fn persistence(message: impl Into<String>) -> Self
Creates a new persistence error with the given message.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::persistence("Disk full");Sourcepub fn state_machine(message: impl Into<String>) -> Self
pub fn state_machine(message: impl Into<String>) -> Self
Creates a new state machine error with the given message.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::state_machine("Invalid command");Sourcepub fn consensus(message: impl Into<String>) -> Self
pub fn consensus(message: impl Into<String>) -> Self
Creates a new consensus error with the given message.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::consensus("Phase mismatch");Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Creates a new internal error with the given message.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::internal("Unexpected condition");Sourcepub fn timeout(operation: impl Into<String>) -> Self
pub fn timeout(operation: impl Into<String>) -> Self
Creates a new timeout error with the given operation.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::timeout("consensus operation");Sourcepub fn serialization(message: impl Into<String>) -> Self
pub fn serialization(message: impl Into<String>) -> Self
Creates a new serialization error with the given message.
§Examples
use rabia_core::RabiaError;
let error = RabiaError::serialization("Invalid JSON");Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Determines if this error condition is potentially recoverable.
Retryable errors are typically transient conditions that may resolve themselves with time or retry attempts. Non-retryable errors usually indicate permanent failures or programming errors.
§Returns
true if the error might be resolved by retrying the operation
§Examples
use rabia_core::RabiaError;
let network_error = RabiaError::network("Connection timeout");
assert!(network_error.is_retryable());
let corruption_error = RabiaError::ChecksumMismatch {
expected: 123,
actual: 456,
};
assert!(!corruption_error.is_retryable());Trait Implementations§
Source§impl Debug for RabiaError
impl Debug for RabiaError
Source§impl Display for RabiaError
impl Display for RabiaError
Source§impl Error for RabiaError
impl Error for RabiaError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()