Skip to main content

Module error

Module error 

Source
Expand description

Generic error wrapper with span tracing.

ICError<E> wraps an error kind E with a SpanTrace captured at the point of construction. Every error type in icechunk is an alias for ICError<SomeErrorKind> (e.g. type SessionError = ICError<SessionErrorKind>).

§Converting errors

Prefer inject over capture when the error is already an ICError, because inject preserves the original span trace while capture replaces it with a new one captured at the current call site.

MethodInputSpan traceUse when
ICError::capturebare error kindnewconstructing a fresh error
.capture()Result<T, E> where E: Into<Kind>newconverting a foreign (non-ICError) result
.capture_box()Result<T, E> where E: Errornewsame, when Kind has From<Box<dyn Error>>
.inject()Result<T, ICError<E>>preservedpropagating between ICError kinds
ICError::injectICError<E>preservedsame, outside of Result

§Examples

Constructing a fresh error — use the type alias, not ICError directly:

Err(SessionError::capture(SessionErrorKind::ReadOnlySession))

Converting a foreign result (e.g. serde, I/O):

serde_json::to_vec(&data).capture()?;          // E: Into<Kind>
builder.build().capture_box()?;                 // E: Error, Kind: From<Box<dyn Error>>
rmp_serde::to_vec(&data).map_err(Box::new).capture()?;  // Kind: From<Box<ConcreteError>>

Propagating between ICError kinds — preserves span trace:

session_fn().inject()?;   // SessionError → RepositoryError

Structs§

ICError

Traits§

ICResultCtxExt
Extension trait for converting Result<T, ICError<E>> into Result<T, ICError<Kind>>, preserving the original span trace.
ICResultExt
Extension trait for converting Result<T, E> into Result<T, ICError<Kind>>, capturing a new span trace.