1#[derive(Debug, Clone)]
3pub enum ErrorKind {
4 Parse,
5 MissingValues,
6 UnsupportedFormatSpec,
7}
8
9#[derive(Debug)]
11pub struct Error {
12 message: String,
13 kind: ErrorKind,
14}
15
16impl std::fmt::Display for Error {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 write!(f, "{}", self.message)
19 }
20}
21
22impl std::error::Error for Error {}
23
24impl Error {
25 pub(crate) fn new_parse(message: String) -> Self {
27 Self {
28 message,
29 kind: ErrorKind::Parse,
30 }
31 }
32
33 pub(crate) fn new_values(message: String) -> Self {
35 Self {
36 message,
37 kind: ErrorKind::MissingValues,
38 }
39 }
40
41 pub(crate) fn new_ufs(message: String) -> Self {
43 Self {
44 message,
45 kind: ErrorKind::UnsupportedFormatSpec,
46 }
47 }
48
49 pub fn message(&self) -> String {
51 self.message.clone()
52 }
53
54 pub fn kind(&self) -> ErrorKind {
56 self.kind.clone()
57 }
58}