Skip to main content

fastsim_schema/v1/
error.rs

1//! Error types for `VehicleSchemaV1` parsing and validation.
2//!
3//! Provides detailed error variants for schema path parsing failures, including
4//! segment count mismatches, invalid formats, and identifier validation issues.
5
6#[derive(Debug, thiserror::Error)]
7pub enum VehicleSchemaV1Error {
8    #[error("expected 8 path segments, got {actual}: {input:?}")]
9    SegmentCount { input: String, actual: usize },
10
11    #[error("expected schema prefix 'v1', got {found:?}")]
12    WrongSchemaPrefix { found: String },
13
14    #[error("expected 'fastsim-N' segment, got {segment:?}")]
15    MissingFastsimVersionPrefix { segment: String },
16
17    #[error("invalid FASTSim version in {segment:?}")]
18    InvalidFastsimVersion {
19        segment: String,
20        #[source]
21        source: std::num::ParseIntError,
22    },
23
24    #[error("expected 'rN' revision segment, got {segment:?}")]
25    MissingRevisionPrefix { segment: String },
26
27    #[error("invalid revision in {segment:?}")]
28    InvalidRevision {
29        segment: String,
30        #[source]
31        source: std::num::ParseIntError,
32    },
33
34    #[error(
35        "{field} contains invalid identifier {value:?}, proper identifier would be {suggestion:?}"
36    )]
37    InvalidIdentifier {
38        field: &'static str,
39        value: String,
40        suggestion: String,
41    },
42}