StreamError

Struct StreamError 

Source
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 occurred
  • context - Context about when and where the error occurred
  • component - Information about the component that encountered the error
  • retries - 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: ComponentInfo

Information about the component that encountered the error.

§retries: usize

Number of times this error has been retried.

Implementations§

Source§

impl<T: Debug + Clone + Send + Sync> StreamError<T>

Source

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> Clone for StreamError<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Debug + Clone + Send + Sync> Debug for StreamError<T>

Source§

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

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

impl<T: Debug + Clone + Send + Sync> Display for StreamError<T>

Source§

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

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

impl<T: Debug + Clone + Send + Sync> Error for StreamError<T>

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§

§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.