jsony/
error.rs

1use crate::json::DecodeError;
2
3/// Error used for FromStr enum implementation
4#[derive(Clone, Copy, Debug)]
5pub struct UnknownVariant;
6
7impl std::fmt::Display for UnknownVariant {
8    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9        f.write_str("Unknown Variant")
10    }
11}
12
13impl std::error::Error for UnknownVariant {}
14
15pub static CUSTOM_FIELD_VALIDATION_ERROR: DecodeError = DecodeError {
16    message: "Parsed value failed validation",
17};
18
19pub static EMPTY_OBJECT_FOR_EXTERNALLY_TAGGED_ENUM: DecodeError = DecodeError {
20    message: "Expected an object containing a single field naming the enum variant but instead found an empty object",
21};
22
23pub static MULTIPLE_FIELDS_FOR_EXTERNALLY_TAGGED_ENUM: DecodeError = DecodeError {
24    message: "Expected an object containing a single field naming the enum variant however the object contains additional fields",
25};
26
27pub static NO_FIELD_MATCHED_AN_ENUM_VARIANT: DecodeError = DecodeError {
28    message: "No fields in the object matched any enum variant",
29};
30
31pub static UNKNOWN_VARIANT: DecodeError = DecodeError {
32    message: "Unknown enum variant",
33};
34
35pub static DUPLICATE_FIELD: DecodeError = DecodeError {
36    message: "Duplicate field",
37};
38
39pub static RECURSION_LIMIT_EXCEEDED: DecodeError = DecodeError {
40    message: "Recursion limit exceeded",
41};
42
43pub static MISSING_REQUIRED_FIELDS: DecodeError = DecodeError {
44    message: "Missing required fields",
45};
46
47pub static MISSING_CONTENT_TAG: DecodeError = DecodeError {
48    message: "Missing content tag",
49};