Skip to main content

bylaw_analyzer/
error.rs

1use bylaw_core::GraphBuildError;
2use camino::Utf8PathBuf;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum AnalyzerError {
7    #[error("manifest path `{0}` does not exist")]
8    ManifestPathDoesNotExist(Utf8PathBuf),
9    #[error("manifest path `{0}` must point to a Cargo.toml file")]
10    InvalidManifestPath(Utf8PathBuf),
11    #[error("invalid analysis options: {0}")]
12    InvalidOptions(String),
13    #[error("requested packages were not found in the workspace: {packages:?}")]
14    UnknownPackages { packages: Vec<String> },
15    #[error("cargo metadata failed for `{manifest_path}`: {source}")]
16    CargoMetadata {
17        manifest_path: Utf8PathBuf,
18        #[source]
19        source: cargo_metadata::Error,
20    },
21    #[error("cargo metadata for `{manifest_path}` did not include a resolve graph")]
22    MissingResolveGraph { manifest_path: Utf8PathBuf },
23    #[error("rust-analyzer workspace load failed for `{manifest_path}`: {message}")]
24    WorkspaceLoad {
25        manifest_path: Utf8PathBuf,
26        message: String,
27    },
28    #[error("failed to read `{path}`: {source}")]
29    ReadFile {
30        path: Utf8PathBuf,
31        #[source]
32        source: std::io::Error,
33    },
34    #[error(transparent)]
35    GraphBuild(#[from] GraphBuildError),
36}