Skip to main content

wslplugins_rs/wsl_version/
parse_error.rs

1use thiserror::Error;
2
3/// Errors returned when parsing a [`super::WSLVersion`] from text.
4#[allow(
5    clippy::enum_variant_names,
6    reason = "These names are more descriptive and easier to understand than the alternatives."
7)]
8#[derive(Debug, Error, Clone, PartialEq, Eq, Hash)]
9pub enum WSLVersionParseError {
10    /// The version string does not follow the supported `major.minor` or
11    /// `major.minor.revision` shape.
12    #[error(
13        "invalid WSL version format: expected 'major.minor' or 'major.minor.revision', got '{input}'"
14    )]
15    InvalidFormat { input: String },
16
17    /// The major component is not a valid `u32`.
18    #[error("invalid WSL version major component in '{input}'")]
19    InvalidMajor { input: String },
20
21    /// The minor component is not a valid `u32`.
22    #[error("invalid WSL version minor component in '{input}'")]
23    InvalidMinor { input: String },
24
25    /// The revision component is not a valid `u32`.
26    #[error("invalid WSL version revision component in '{input}'")]
27    InvalidRevision { input: String },
28}