Skip to main content

RabiaError

Enum RabiaError 

Source
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

Fields

§message: String
§

Persistence

Persistent storage operation failure

Fields

§message: String
§

StateMachine

State machine execution failure

Fields

§message: String
§

Consensus

Consensus protocol violation or failure

Fields

§message: String
§

NodeNotFound

Referenced node was not found in the cluster

Fields

§node_id: NodeId
§

PhaseNotFound

Referenced consensus phase was not found

Fields

§phase_id: PhaseId
§

BatchNotFound

Referenced command batch was not found

Fields

§batch_id: BatchId
§

InvalidStateTransition

Invalid state machine transition attempted

Fields

§from: String
§

QuorumNotAvailable

Insufficient nodes available to form a quorum

Fields

§current: usize
§required: usize
§

ChecksumMismatch

Data integrity check failed due to checksum mismatch

Fields

§expected: u32
§actual: u32
§

StateCorruption

State corruption detected in persistent storage

Fields

§details: String
§

PartialWrite

Incomplete write operation detected

Fields

§details: String
§

Timeout

Operation exceeded its timeout limit

Fields

§operation: String
§

Serialization(Error)

JSON serialization/deserialization failure

§

Io(Error)

File system or network I/O failure

§

Internal

Unexpected internal error

Fields

§message: String

Implementations§

Source§

impl RabiaError

Source

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");
Source

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");
Source

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");
Source

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");
Source

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");
Source

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");
Source

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");
Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for RabiaError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for RabiaError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for RabiaError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for RabiaError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.