Skip to main content

components_rs/
error.rs

1//! Shared error type for all fallible operations in this crate.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum ComponentsJsError {
7    #[error("IO error: {0}")]
8    Io(#[from] std::io::Error),
9
10    #[error("JSON parse error in {path}: {source}")]
11    JsonParse {
12        path: String,
13        source: serde_json::Error,
14    },
15
16    #[error("Semver error for version '{version}': {message}")]
17    Semver { version: String, message: String },
18
19    #[error("Context resolution error: {0}")]
20    ContextResolution(String),
21
22    #[error("Missing required field '{field}' in {location}")]
23    MissingField { field: String, location: String },
24
25    #[error("Invalid URL: {0}")]
26    InvalidUrl(String),
27
28    #[error("{0}")]
29    General(String),
30}
31
32pub type Result<T> = std::result::Result<T, ComponentsJsError>;