pub struct StreamError<T: Debug + Clone + Send + Sync> {
pub source: Box<dyn Error + Send + Sync>,
pub context: ErrorContext<T>,
pub component: ComponentInfo,
pub retries: usize,
}Expand description
Error that occurred during stream processing.
This error type provides rich context about where and when an error occurred, making it easier to debug and handle errors appropriately.
§Fields
source- The original error that occurredcontext- Context about when and where the error occurredcomponent- Information about the component that encountered the errorretries- Number of times this error has been retried
§Example
use streamweave::error::{StreamError, ErrorContext, ComponentInfo};
use std::error::Error;
let error = StreamError::new(
Box::new(std::io::Error::new(std::io::ErrorKind::NotFound, "File not found")),
ErrorContext {
timestamp: chrono::Utc::now(),
item: Some(42),
component_name: "FileProducer".to_string(),
component_type: "Producer".to_string(),
},
ComponentInfo {
name: "file-producer".to_string(),
type_name: "FileProducer".to_string(),
},
);Fields§
§source: Box<dyn Error + Send + Sync>The original error that occurred.
context: ErrorContext<T>Context about when and where the error occurred.
component: ComponentInfoInformation about the component that encountered the error.
retries: usizeNumber of times this error has been retried.
Implementations§
Source§impl<T: Debug + Clone + Send + Sync> StreamError<T>
impl<T: Debug + Clone + Send + Sync> StreamError<T>
Sourcepub fn new(
source: Box<dyn Error + Send + Sync>,
context: ErrorContext<T>,
component: ComponentInfo,
) -> Self
pub fn new( source: Box<dyn Error + Send + Sync>, context: ErrorContext<T>, component: ComponentInfo, ) -> Self
Creates a new StreamError with the given source error, context, and component information.
§Arguments
source- The original error that occurred.context- Context about when and where the error occurred.component- Information about the component that encountered the error.
§Returns
A new StreamError with retries set to 0.
Trait Implementations§
Source§impl<T: Debug + Clone + Send + Sync> Error for StreamError<T>
impl<T: Debug + Clone + Send + Sync> Error for StreamError<T>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl<T> Freeze for StreamError<T>where
T: Freeze,
impl<T> !RefUnwindSafe for StreamError<T>
impl<T> Send for StreamError<T>
impl<T> Sync for StreamError<T>
impl<T> Unpin for StreamError<T>where
T: Unpin,
impl<T> !UnwindSafe for StreamError<T>
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
Mutably borrows from an owned value. Read more