Skip to main content

panproto_project/
error.rs

1//! Error types for project assembly operations.
2
3use miette::Diagnostic;
4
5/// Errors from multi-file project assembly.
6#[non_exhaustive]
7#[derive(Debug, thiserror::Error, Diagnostic)]
8pub enum ProjectError {
9    /// A file could not be parsed.
10    #[error("failed to parse {path}: {reason}")]
11    ParseFailed {
12        /// The file path that failed.
13        path: String,
14        /// The reason parsing failed.
15        reason: String,
16    },
17
18    /// Language detection failed for a file.
19    #[error("unknown language for {path}")]
20    UnknownLanguage {
21        /// The file path with unrecognized language.
22        path: String,
23    },
24
25    /// Schema coproduct construction failed.
26    #[error("coproduct construction failed: {reason}")]
27    CoproductFailed {
28        /// Description of the construction failure.
29        reason: String,
30    },
31
32    /// A cross-file import could not be resolved.
33    #[error("unresolved import in {source_file}: {import_target}")]
34    UnresolvedImport {
35        /// The file containing the unresolved import.
36        source_file: String,
37        /// The target that could not be resolved.
38        import_target: String,
39    },
40
41    /// An I/O error occurred reading files.
42    #[error("I/O error: {0}")]
43    Io(#[from] std::io::Error),
44
45    /// A parse error propagated from panproto-parse.
46    #[error(transparent)]
47    Parse(#[from] panproto_parse::ParseError),
48}