FluxionError

Enum FluxionError 

Source
pub enum FluxionError {
    LockError {
        context: String,
    },
    ChannelSendError,
    ChannelReceiveError {
        reason: String,
    },
    StreamProcessingError {
        context: String,
    },
    CallbackPanic {
        context: String,
    },
    SubscriptionError {
        context: String,
    },
    InvalidState {
        message: String,
    },
    Timeout {
        operation: String,
        duration: Duration,
    },
    UnexpectedStreamEnd {
        expected: usize,
        actual: usize,
    },
    ResourceLimitExceeded {
        resource: String,
        limit: usize,
    },
    UserError(Box<dyn Error + Send + Sync>),
    MultipleErrors {
        count: usize,
        errors: Vec<FluxionError>,
    },
}
Expand description

Root error type for all Fluxion operations

This enum encompasses all possible error conditions that can occur during stream processing, subscription, and channel operations.

Variants§

§

LockError

Error acquiring a lock on shared state

This typically indicates contention or a poisoned mutex. The context provides details about which lock failed.

Fields

§context: String

Description of the lock that failed

§

ChannelSendError

Channel send operation failed

This occurs when attempting to send to a channel whose receiver has been dropped.

§

ChannelReceiveError

Channel receive operation failed

This can occur when the channel is closed, empty, or in an invalid state.

Fields

§reason: String

Specific reason for the receive failure

§

StreamProcessingError

Stream processing encountered an error

This is a general error for stream operations that don’t fit other specific categories.

Fields

§context: String

Description of what went wrong during stream processing

§

CallbackPanic

User-provided callback function panicked

When a user-supplied closure or function panics during stream processing, it’s caught and converted to this error variant.

Fields

§context: String

Information about the panic location and cause

§

SubscriptionError

Subscription operation failed

This encompasses errors during subscribe_async or subscribe_latest_async operations, including user callback errors when no error handler is provided.

Fields

§context: String

Details about the subscription failure

§

InvalidState

Invalid state encountered

This indicates that an operation was attempted when the stream or channel was in an inappropriate state.

Fields

§message: String

Description of the invalid state

§

Timeout

Timeout occurred while waiting for an operation

Used when operations have time limits and they expire.

Fields

§operation: String

The operation that timed out

§duration: Duration

How long we waited

§

UnexpectedStreamEnd

Stream unexpectedly ended

This occurs when more items were expected but the stream terminated.

Fields

§expected: usize

Number of items expected

§actual: usize

Number of items actually received

§

ResourceLimitExceeded

Resource limit exceeded

This indicates that a buffer, queue, or other bounded resource is full.

Fields

§resource: String

Name of the resource that hit its limit

§limit: usize

The limit that was exceeded

§

UserError(Box<dyn Error + Send + Sync>)

Custom error from user code

This wraps errors produced by user-provided functions and callbacks, allowing them to be propagated through the Fluxion error system.

§

MultipleErrors

Multiple errors occurred

When processing multiple items in parallel, multiple failures can occur. This variant aggregates them.

Fields

§count: usize

Number of errors that occurred

§errors: Vec<FluxionError>

The individual errors (limited to prevent unbounded growth)

Implementations§

Source§

impl FluxionError

Source

pub fn lock_error(context: impl Into<String>) -> Self

Create a lock error with the given context

Source

pub fn stream_error(context: impl Into<String>) -> Self

Create a stream processing error with the given context

Source

pub fn invalid_state(message: impl Into<String>) -> Self

Create an invalid state error with the given message

Source

pub fn subscription_error(context: impl Into<String>) -> Self

Create a subscription error with the given context

Source

pub fn channel_receive_error(reason: impl Into<String>) -> Self

Create a channel receive error with the given reason

Source

pub fn timeout(operation: impl Into<String>, duration: Duration) -> Self

Create a timeout error

Source

pub const fn unexpected_end(expected: usize, actual: usize) -> Self

Create an unexpected stream end error

Source

pub fn resource_limit(resource: impl Into<String>, limit: usize) -> Self

Create a resource limit exceeded error

Source

pub fn user_error(error: impl Error + Send + Sync + 'static) -> Self

Wrap a user error

Source

pub fn from_user_errors<E>(errors: Vec<E>) -> Self
where E: Error + Send + Sync + 'static,

Aggregate multiple user errors into a MultipleErrors variant

This is useful for collecting errors from stream subscribers that don’t have error callbacks, allowing them to be propagated as a single error.

§Examples
use fluxion_error::FluxionError;

#[derive(Debug, thiserror::Error)]
#[error("Custom error: {msg}")]
struct CustomError {
    msg: String,
}

let errors = vec![
    CustomError { msg: "first".to_string() },
    CustomError { msg: "second".to_string() },
];

let result = FluxionError::from_user_errors(errors);
assert!(matches!(result, FluxionError::MultipleErrors { count: 2, .. }));
Source

pub const fn is_recoverable(&self) -> bool

Check if this is a recoverable error

Some errors indicate transient failures that could succeed on retry.

Source

pub const fn is_permanent(&self) -> bool

Check if this error indicates a permanent failure

Trait Implementations§

Source§

impl Debug for FluxionError

Source§

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

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

impl Display for FluxionError

Source§

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

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

impl Error for FluxionError

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

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<E> IntoFluxionError for E
where E: Error + Send + Sync + 'static,

Source§

fn into_fluxion_error(self, _context: &str) -> FluxionError

Convert this error into a FluxionError with additional context
Source§

fn into_fluxion(self) -> FluxionError
where Self: Sized,

Convert this error into a FluxionError without additional context
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.