use std::path::PathBuf;
use crate::integrity::Sha256Digest;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ContentError {
#[error("no content bundle is installed: {} does not exist", lock_path.display())]
NotInstalled {
lock_path: PathBuf,
},
#[error("could not read the content lock {}: {source}", path.display())]
LockUnreadable {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("the content lock {} is invalid: {reason}", path.display())]
LockInvalid {
path: PathBuf,
reason: String,
},
#[error("{tag:?} is not a content release tag (expected content-vX.Y.Z[-pre])")]
InvalidTag {
tag: String,
},
#[error("could not write the content lock {}: {source}", path.display())]
LockWrite {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("the pinned content bundle {} is missing", path.display())]
BundleMissing {
path: PathBuf,
},
#[error("could not read the content bundle {}: {source}", path.display())]
BundleUnreadable {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error(
"refusing to load the content bundle {}: the lock pins sha256 {expected}, \
but the bundle hashes to {actual}",
path.display()
)]
ChecksumMismatch {
path: PathBuf,
expected: Sha256Digest,
actual: Sha256Digest,
},
#[error("the content bundle {} is malformed: {reason}", path.display())]
BundleCorrupt {
path: PathBuf,
reason: String,
},
#[error("refusing to load the content bundle {}: {reason}", path.display())]
BundleTooLarge {
path: PathBuf,
reason: String,
},
#[error("the lock pins {lock_tag}, but the bundle's manifest says {bundle_tag}")]
TagMismatch {
lock_tag: String,
bundle_tag: String,
},
#[error(
"refusing to load the content bundle {}: it declares schema_major {bundle}, \
and this binary reads schema_major {supported} or older; upgrade tm, or pin \
an older content release",
path.display()
)]
UnsupportedSchema {
path: PathBuf,
bundle: u32,
supported: u32,
},
#[error("{} is not a content checkout: {} is missing", root.display(), missing.display())]
NotACheckout {
root: PathBuf,
missing: PathBuf,
},
#[error("refusing to read content from {}: {reason}", root.display())]
UntrustedCheckout {
root: PathBuf,
reason: String,
},
#[error("{path:?} is not a relative content path")]
InvalidPath {
path: String,
},
#[error("{class:?} is not a content class (expected agents, skills or instructions)")]
UnknownClass {
class: String,
},
#[error("content path {path:?} does not exist")]
NotFound {
path: String,
},
#[error("could not read {}: {source}", path.display())]
Io {
path: PathBuf,
#[source]
source: std::io::Error,
},
}