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.
| Method | Input | Span trace | Use when |
|---|---|---|---|
ICError::capture | bare error kind | new | constructing a fresh error |
.capture() | Result<T, E> where E: Into<Kind> | new | converting a foreign (non-ICError) result |
.capture_box() | Result<T, E> where E: Error | new | same, when Kind has From<Box<dyn Error>> |
.inject() | Result<T, ICError<E>> | preserved | propagating between ICError kinds |
ICError::inject | ICError<E> | preserved | same, 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 → RepositoryErrorStructs§
Traits§
- ICResult
CtxExt - Extension trait for converting
Result<T, ICError<E>>intoResult<T, ICError<Kind>>, preserving the original span trace. - ICResult
Ext - Extension trait for converting
Result<T, E>intoResult<T, ICError<Kind>>, capturing a new span trace.