1use std::fmt::Display;
2
3#[derive(Debug, PartialEq, Eq)]
4#[non_exhaustive]
5pub enum Error {
6 EqualsNotFound,
8 NameEmpty,
9 InvalidName,
10 InvalidValue,
11
12 ExpiresFmt,
14
15 PercentDecodeError,
17
18 InvalidPathValue,
20 EmptyPathValue,
21}
22
23impl Display for Error {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 let err = match self {
26 Error::EqualsNotFound => "No '=' found in the cookie",
27 Error::NameEmpty => "The cookie name is empty",
28 Error::InvalidName => "The cookie name contains an invalid character",
29 Error::InvalidValue => "The cookie value contains an invalid value",
30 Error::ExpiresFmt => "Failed to format the expires value",
31 Error::PercentDecodeError => "An error occured while decoding",
32 Error::InvalidPathValue => "The path attribute contains an invalid value",
33 Error::EmptyPathValue => "The path attribute is empty",
34 };
35
36 f.write_str(err)
37 }
38}
39
40impl std::error::Error for Error {}