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.
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.
StreamProcessingError
Stream processing encountered an error
This is a general error for stream operations that don’t fit other specific categories.
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.
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.
InvalidState
Invalid state encountered
This indicates that an operation was attempted when the stream or channel was in an inappropriate state.
Timeout
Timeout occurred while waiting for an operation
Used when operations have time limits and they expire.
UnexpectedStreamEnd
Stream unexpectedly ended
This occurs when more items were expected but the stream terminated.
ResourceLimitExceeded
Resource limit exceeded
This indicates that a buffer, queue, or other bounded resource is full.
Fields
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
errors: Vec<FluxionError>The individual errors (limited to prevent unbounded growth)
Implementations§
Source§impl FluxionError
impl FluxionError
Sourcepub fn lock_error(context: impl Into<String>) -> Self
pub fn lock_error(context: impl Into<String>) -> Self
Create a lock error with the given context
Sourcepub fn stream_error(context: impl Into<String>) -> Self
pub fn stream_error(context: impl Into<String>) -> Self
Create a stream processing error with the given context
Sourcepub fn invalid_state(message: impl Into<String>) -> Self
pub fn invalid_state(message: impl Into<String>) -> Self
Create an invalid state error with the given message
Sourcepub fn subscription_error(context: impl Into<String>) -> Self
pub fn subscription_error(context: impl Into<String>) -> Self
Create a subscription error with the given context
Sourcepub fn channel_receive_error(reason: impl Into<String>) -> Self
pub fn channel_receive_error(reason: impl Into<String>) -> Self
Create a channel receive error with the given reason
Sourcepub fn timeout(operation: impl Into<String>, duration: Duration) -> Self
pub fn timeout(operation: impl Into<String>, duration: Duration) -> Self
Create a timeout error
Sourcepub const fn unexpected_end(expected: usize, actual: usize) -> Self
pub const fn unexpected_end(expected: usize, actual: usize) -> Self
Create an unexpected stream end error
Sourcepub fn resource_limit(resource: impl Into<String>, limit: usize) -> Self
pub fn resource_limit(resource: impl Into<String>, limit: usize) -> Self
Create a resource limit exceeded error
Sourcepub fn user_error(error: impl Error + Send + Sync + 'static) -> Self
pub fn user_error(error: impl Error + Send + Sync + 'static) -> Self
Wrap a user error
Sourcepub fn from_user_errors<E>(errors: Vec<E>) -> Self
pub fn from_user_errors<E>(errors: Vec<E>) -> Self
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, .. }));Sourcepub const fn is_recoverable(&self) -> bool
pub const fn is_recoverable(&self) -> bool
Check if this is a recoverable error
Some errors indicate transient failures that could succeed on retry.
Sourcepub const fn is_permanent(&self) -> bool
pub const fn is_permanent(&self) -> bool
Check if this error indicates a permanent failure
Trait Implementations§
Source§impl Debug for FluxionError
impl Debug for FluxionError
Source§impl Display for FluxionError
impl Display for FluxionError
Source§impl Error for FluxionError
impl Error for FluxionError
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
Auto Trait Implementations§
impl Freeze for FluxionError
impl !RefUnwindSafe for FluxionError
impl Send for FluxionError
impl Sync for FluxionError
impl Unpin for FluxionError
impl !UnwindSafe for FluxionError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<E> IntoFluxionError for E
impl<E> IntoFluxionError for E
Source§fn into_fluxion_error(self, _context: &str) -> FluxionError
fn into_fluxion_error(self, _context: &str) -> FluxionError
FluxionError with additional contextSource§fn into_fluxion(self) -> FluxionErrorwhere
Self: Sized,
fn into_fluxion(self) -> FluxionErrorwhere
Self: Sized,
FluxionError without additional context