1use thiserror::Error;
2
3#[derive(Debug, Error, PartialEq, Clone, Default)]
5#[doc(hidden)]
6pub enum LexError {
7 #[default]
9 #[error("vcard lex error")]
10 Other,
11}
12
13#[derive(Debug, Error)]
15pub enum Error {
16 #[error("input token was expected but reached EOF")]
19 TokenExpected,
20
21 #[error("version must be the first property")]
24 VersionMisplaced,
25
26 #[error("control characters are not allowed, got '{0}'")]
28 ControlCharacter(String),
29
30 #[error("input token '{0}' was incorrect")]
32 IncorrectToken(String),
33
34 #[error("unknown parameter '{0}'")]
36 UnknownParameter(String),
37
38 #[error("property name '{0}' is not supported")]
40 UnknownPropertyName(String),
41
42 #[error("property value is invalid")]
44 InvalidPropertyValue,
45
46 #[error("time '{0}' is invalid")]
48 InvalidTime(String),
49
50 #[error("date '{0}' is invalid")]
52 InvalidDate(String),
53
54 #[error("delivery address '{0}' is invalid")]
56 InvalidAddress(String),
57
58 #[error("parameter LABEL can only be applied to ADR but used on '{0}'")]
61 InvalidLabel(String),
62
63 #[error("value '{0}' is not a valid boolean")]
65 InvalidBoolean(String),
66
67 #[error("client PID map '{0}' is not valid")]
69 InvalidClientPidMap(String),
70
71 #[error("property or parameter delimiter expected")]
73 DelimiterExpected,
74
75 #[error("value type '{0}' is not supported")]
77 UnknownValueType(String),
78
79 #[error("related type value '{0}' is not supported")]
81 UnknownRelatedType(String),
82
83 #[error("telephone type value '{0}' is not supported")]
85 UnknownTelephoneType(String),
86
87 #[error("value '{0}' is not supported in this context '{1}'")]
89 UnsupportedValueType(String, String),
90
91 #[error("kind '{0}' is not supported")]
93 UnknownKind(String),
94
95 #[error("sex '{0}' is not supported")]
97 UnknownSex(String),
98
99 #[error("gender value is missing sex")]
101 NoSex,
102
103 #[error("property '{0}' may only appear exactly once")]
105 OnlyOnce(String),
106
107 #[error("formatted name (FN) is required")]
109 NoFormattedName,
110
111 #[error("date time '{0}' is not valid, maybe missing 'T' delimiter")]
113 InvalidDateTime(String),
114
115 #[error("TYPE parameter is not supported for property '{0}'")]
118 TypeParameter(String),
119
120 #[error("pref '{0}' is out of bounds, must be between 1 and 100")]
122 PrefOutOfRange(u8),
123
124 #[error("pid '{0}' is invalid")]
126 InvalidPid(String),
127
128 #[error("'{0}' must be enclosed in quotes")]
131 NotQuoted(String),
132
133 #[error("member property is only allowed when the kind is group")]
135 MemberRequiresGroup,
136
137 #[error("PID parameter not allowed for CLIENTPIDMAP")]
140 ClientPidMapPidNotAllowed,
141
142 #[cfg(feature = "language-tags")]
144 #[error(transparent)]
145 LanguageParse(#[from] language_tags::ParseError),
146
147 #[error(transparent)]
149 UriParse(#[from] uriparse::uri::URIError),
150
151 #[error(transparent)]
153 ComponentRange(#[from] time::error::ComponentRange),
154
155 #[error(transparent)]
157 TimeParse(#[from] time::error::Parse),
158
159 #[error(transparent)]
161 TimeFormat(#[from] time::error::Format),
162
163 #[error(transparent)]
165 TimeInvalidFormat(#[from] time::error::InvalidFormatDescription),
166
167 #[error(transparent)]
169 ParseInt(#[from] std::num::ParseIntError),
170
171 #[error(transparent)]
173 ParseFloat(#[from] std::num::ParseFloatError),
174
175 #[cfg(feature = "mime")]
177 #[error(transparent)]
178 Mime(#[from] mime::FromStrError),
179
180 #[error(transparent)]
182 Base64(#[from] base64::DecodeError),
183
184 #[error(transparent)]
186 LexError(#[from] LexError),
187
188 #[error("CHARSET='{0}' is invalid, expected UTF-8")]
190 CharsetParameter(String),
191}