toargv_template/error.rs
1use thiserror::Error;
2
3/// An invalid template or argument-expansion failure.
4#[derive(Debug, Error)]
5pub enum Error {
6 /// A dotted configuration path is invalid.
7 #[error("invalid configuration path `{path}`: {message}")]
8 InvalidPath {
9 /// The invalid path.
10 path: String,
11 /// Why the path is invalid.
12 message: String,
13 },
14
15 /// A template argument contains invalid syntax.
16 #[error("invalid template argument {argument} at byte {offset}: {message}")]
17 Parse {
18 /// One-based position in the template argument vector.
19 argument: usize,
20 /// Byte offset within the argument.
21 offset: usize,
22 /// Why parsing failed.
23 message: String,
24 },
25
26 /// A strict placeholder's configuration path is missing or null.
27 #[error("configuration path `{path}` was not found")]
28 MissingValue {
29 /// The unresolved dotted configuration path.
30 path: String,
31 /// One-based position in the template argument vector.
32 argument: usize,
33 },
34
35 /// A configuration value is incompatible with its placeholder.
36 #[error("cannot expand configuration path `{path}`: {message}")]
37 Expansion {
38 /// One-based position in the template argument vector.
39 argument: usize,
40 /// The dotted configuration path that resolved to the value.
41 path: String,
42 /// Why the value and placeholder are incompatible.
43 message: String,
44 },
45}