1pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 #[error("Unsupported or unrecognized container format")]
11 UnsupportedFormat,
12
13 #[error("Container index parse failed: {reason}")]
15 ParseFailed { reason: String },
16
17 #[error("Seek index not found in probe: {reason}")]
22 IndexNotFound { reason: String },
23
24 #[error("Extra Range fetch failed: {0}")]
26 FetchFailed(Box<dyn std::error::Error + Send + Sync>),
27}
28
29impl Error {
30 pub(crate) fn parse(reason: impl Into<String>) -> Self {
32 let reason = reason.into();
33 tracing::warn!(reason = %reason, "Container index parse failed");
34 Self::ParseFailed { reason }
35 }
36
37 pub(crate) fn index_not_found(reason: impl Into<String>) -> Self {
39 let reason = reason.into();
40 tracing::warn!(reason = %reason, "Seek index not found in probe");
41 Self::IndexNotFound { reason }
42 }
43
44 pub(crate) fn fetch<E: std::error::Error + Send + Sync + 'static>(source: E) -> Self {
46 tracing::warn!(error = %source, "Extra Range fetch failed");
47 Self::FetchFailed(Box::new(source))
48 }
49}