Skip to main content

crate_seq_core/
error.rs

1//! Error type for core orchestration operations.
2
3/// All errors that can occur in crate-seq-core operations.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// Filesystem I/O failure reading a manifest or ledger.
7    #[error("I/O error reading {path}: {source}")]
8    Io {
9        /// The path being read when the error occurred.
10        path: std::path::PathBuf,
11        /// The underlying I/O error.
12        #[source]
13        source: std::io::Error,
14    },
15    /// TOML parse failure in a workspace or crate manifest.
16    #[error("TOML parse error in {path}: {source}")]
17    Toml {
18        /// The path of the file that failed to parse.
19        path: std::path::PathBuf,
20        /// The underlying TOML error.
21        #[source]
22        source: toml_edit::TomlError,
23    },
24    /// A `Cargo.toml` is missing a `[package].name` field.
25    #[error("missing [package].name in {0}")]
26    MissingPackageName(std::path::PathBuf),
27    /// A named crate was not found among workspace members.
28    #[error("crate '{0}' not found in workspace")]
29    CrateNotFound(String),
30    /// Ledger file not found at the given path.
31    #[error("ledger not found at {0}")]
32    LedgerNotFound(std::path::PathBuf),
33    /// Git tag discovery failed.
34    #[error("git error: {0}")]
35    Git(#[from] crate_seq_git::Error),
36    /// Registry query failed.
37    #[error("registry error: {0}")]
38    Registry(#[from] crate_seq_registry::Error),
39    /// Ledger I/O or state-machine error.
40    #[error("ledger error: {0}")]
41    Ledger(#[from] crate_seq_ledger::Error),
42    /// Manifest rewrite or path-dep scan failed.
43    #[error("manifest error: {0}")]
44    Manifest(#[from] crate_seq_manifest::Error),
45    /// Subprocess could not be spawned or failed to complete.
46    #[error("subprocess error: {0}")]
47    Subprocess(String),
48    /// Path dependencies found in the manifest; lists all offending dep names.
49    #[error("path dependencies found in {manifest}: {}", deps.join(", "))]
50    PathDependencies {
51        /// The manifest that contains path dependencies.
52        manifest: std::path::PathBuf,
53        /// Names of all path-dependent crates found.
54        deps: Vec<String>,
55    },
56    /// `cargo check` exited non-zero.
57    #[error("cargo check failed:\n{stderr}")]
58    CargoCheck {
59        /// The stderr output from `cargo check`.
60        stderr: String,
61    },
62    /// Token resolution failed; contains actionable setup instructions.
63    #[error("token resolution failed: {0}")]
64    TokenResolution(String),
65    /// The version is already tracked in the ledger.
66    #[error("version {0} is already tracked in the ledger")]
67    VersionAlreadyTracked(semver::Version),
68    /// A git tag with this name already exists in the repository.
69    #[error("tag '{0}' already exists in the repository")]
70    TagAlreadyExists(String),
71    /// The semver string provided could not be parsed.
72    #[error("invalid version '{input}': {source}")]
73    InvalidVersion {
74        /// The raw string that failed to parse.
75        input: String,
76        /// The underlying parse error.
77        #[source]
78        source: semver::Error,
79    },
80    /// Snapshot capture or hashing failed.
81    #[error("snapshot error: {0}")]
82    Snapshot(String),
83    /// No tarball found in the snapshot store matching the expected SHA-256.
84    #[error("snapshot not found: no tarball with hash {0} in store")]
85    SnapshotNotFound(String),
86
87    /// Workspace dependency graph contains a cycle.
88    #[error("dependency cycle detected among: {}", crate_names.join(", "))]
89    DependencyCycle {
90        /// Names of crates involved in the cycle.
91        crate_names: Vec<String>,
92    },
93}