1use std::path::PathBuf;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error("{operation}: {path}: {source}")]
8 Io {
9 operation: &'static str,
10 path: PathBuf,
11 #[source]
12 source: std::io::Error,
13 },
14 #[error("invalid TOML: {0}")]
15 Parse(#[from] toml::de::Error),
16 #[error("manifest validation failed:\n{}", .0.join("\n"))]
17 Validation(Vec<String>),
18 #[error("{0}")]
19 Invalid(String),
20 #[error("{0}")]
21 RecoveryRequired(Box<crate::journal::WriteBlocker>),
22 #[error("another Dort writer holds the application lock")]
23 Locked,
24 #[error("no active repository; use --repo or --manifest")]
25 NoRepository,
26}
27
28pub(crate) fn io_error(
29 operation: &'static str,
30 path: impl Into<PathBuf>,
31 source: impl Into<std::io::Error>,
32) -> Error {
33 Error::Io {
34 operation,
35 path: path.into(),
36 source: source.into(),
37 }
38}