Skip to main content

changeset_manifest/
error.rs

1use std::path::PathBuf;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum ManifestError {
7    #[error("failed to read manifest at '{path}'")]
8    Read {
9        path: PathBuf,
10        #[source]
11        source: std::io::Error,
12    },
13
14    #[error("failed to write manifest at '{path}'")]
15    Write {
16        path: PathBuf,
17        #[source]
18        source: std::io::Error,
19    },
20
21    #[error("failed to parse TOML at '{path}'")]
22    Parse {
23        path: PathBuf,
24        #[source]
25        source: toml_edit::TomlError,
26    },
27
28    #[error("missing required field '{field}' in '{path}'")]
29    MissingField { path: PathBuf, field: String },
30
31    #[error("expected version '{expected}' but found '{actual}' in '{path}'")]
32    VerificationFailed {
33        path: PathBuf,
34        expected: String,
35        actual: String,
36    },
37
38    #[error("invalid version string '{version}' in '{path}'")]
39    InvalidVersion {
40        path: PathBuf,
41        version: String,
42        #[source]
43        source: semver::Error,
44    },
45
46    #[error("missing section '{section}' in manifest '{path}'")]
47    MissingSection { path: PathBuf, section: String },
48
49    #[error("expected '{section}' to be a table in manifest '{path}'")]
50    InvalidSectionType { path: PathBuf, section: String },
51
52    #[error("failed to parse YAML at '{path}'")]
53    YamlParse {
54        path: PathBuf,
55        #[source]
56        source: yaml_edit::YamlError,
57    },
58
59    #[error("failed to parse JSON at '{path}'")]
60    JsonParse {
61        path: PathBuf,
62        #[source]
63        source: jsonc_parser::errors::ParseError,
64    },
65
66    #[error("failed to decode JSON string at '{path}'")]
67    JsonStringDecode {
68        path: PathBuf,
69        #[source]
70        source: jsonc_parser::ParseStringErrorKind,
71    },
72
73    #[error("version path '{version_field_path}' not found in manifest at '{path}'")]
74    VersionPathNotFound {
75        path: PathBuf,
76        version_field_path: String,
77    },
78
79    #[error("expected string at version path '{version_field_path}' in manifest at '{path}'")]
80    VersionNotString {
81        path: PathBuf,
82        version_field_path: String,
83    },
84}