gen_gomod/error.rs
1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum GomodError {
5 #[error("manifest not found: {0}")]
6 ManifestNotFound(std::path::PathBuf),
7 /// A triplet-interpreter phase failed. `phase` names the exact
8 /// step (`go-list`, `parse-go-list`, `read-source`, `resolve-imports`,
9 /// …) so consumers see the gap mechanically — never a silent wrong
10 /// answer (TYPED-SPEC + INTERPRETER TRIPLET discipline).
11 #[error("interp phase `{phase}`: {detail}")]
12 Interp { phase: &'static str, detail: String },
13 /// The `go list` subprocess itself failed (non-zero exit / spawn
14 /// error). Distinct from a parse failure so the operator can tell a
15 /// missing-`go` / bad-vendor-tree from malformed JSON.
16 #[error("`go list` failed: {0}")]
17 GoList(String),
18 /// `go list -json` output did not parse as a concatenated stream of
19 /// package objects.
20 #[error("parsing `go list -json` output: {0}")]
21 GoListParse(String),
22 /// A source file named by `go list` could not be read for hashing.
23 #[error("read {path}: {source}")]
24 Io {
25 path: std::path::PathBuf,
26 #[source]
27 source: std::io::Error,
28 },
29 #[error("other: {0}")]
30 Other(String),
31}
32
33pub type Result<T> = std::result::Result<T, GomodError>;