Skip to main content

clayers_repo/
error.rs

1//! Error types for repository operations.
2
3use clayers_xml::ContentHash;
4
5/// Errors from repository operations.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// An XML processing error from clayers-xml.
9    #[error("XML error: {0}")]
10    Xml(#[from] clayers_xml::Error),
11
12    /// An XML parsing error from xot.
13    #[error("XML parse error: {0}")]
14    XmlParse(String),
15
16    /// A storage backend error.
17    #[error("storage error: {0}")]
18    Storage(String),
19
20    /// A requested object was not found in the store.
21    #[error("object not found: {0}")]
22    NotFound(ContentHash),
23
24    /// An object could not be interpreted or is structurally invalid.
25    #[error("invalid object: {0}")]
26    InvalidObject(String),
27
28    /// A ref operation error (branch, tag, HEAD).
29    #[error("ref error: {0}")]
30    Ref(String),
31
32    /// A document with no root element was encountered.
33    #[error("empty document: no root element")]
34    EmptyDocument,
35}
36
37impl From<xot::Error> for Error {
38    fn from(e: xot::Error) -> Self {
39        Self::XmlParse(e.to_string())
40    }
41}
42
43/// Convenience alias for `Result<T, Error>`.
44pub type Result<T> = std::result::Result<T, Error>;