mapstic_derive_impl/
error.rs

1use thiserror::Error;
2
3/// Errors that may be returned when deriving [`mapstic_core::ToMapping`].
4#[derive(Debug, Error)]
5pub enum Error {
6    #[error(
7        "{}; {}, {}",
8        "all fields in the struct were skipped",
9        "consider using #[mapstic(skip)] to skip the field",
10        "or #[mapstic(mapping_type = ...)] to specify the desired type"
11    )]
12    AllSkipped,
13
14    #[error(
15        "{}; {}",
16        "cannot generate mapping for enums",
17        "consider using #[mapstic(mapping_type = ...)] to specify an explicit mapping type"
18    )]
19    Enum,
20
21    // Left implied: how did this even get parsed in the first place?
22    #[error("a tuple field was found in a named struct")]
23    MixedStruct,
24
25    #[error(
26        "{}; {}, {}",
27        "a type cannot be derived from tuple structs with multiple fields",
28        "consider using #[mapstic(mapping_type = ...)] to specify the desired type",
29        "or #[mapstic(skip)] to ignore the field"
30    )]
31    TupleStruct,
32
33    #[error(
34        "{}; {}, {}",
35        "a type cannot be derived from unit structs",
36        "consider using #[mapstic(mapping_type = ...)] to specify the desired type",
37        "or #[mapstic(skip)] to ignore the field"
38    )]
39    UnitStruct,
40}