1use std::fmt;
4use std::io;
5
6#[derive(Debug, thiserror::Error)]
7pub(crate) enum ErrorInner {
8 #[error("{0}")]
9 Custom(String),
10 #[error("Line {0} doesn't contain a colon")]
11 MissingColon(usize),
12 #[error("I/O error")]
13 IoError(#[from] io::Error),
14 #[error("The deserialized type is ambiguous and must be explicitly specified. (RFC822 is NOT self-describing.)")]
15 AmbiguousType,
16}
17
18impl serde::de::Error for Error {
19 fn custom<T: fmt::Display>(msg: T) -> Self {
20 ErrorInner::Custom(msg.to_string()).into()
21 }
22}
23
24#[derive(Debug, thiserror::Error)]
31#[error(transparent)]
32pub struct Error(#[from] ErrorInner);
33
34#[derive(Debug, thiserror::Error)]
36pub enum ReadFileError {
37 #[error("failed to open file {path} for reading")]
39 Open {
40 path: std::path::PathBuf,
42 #[source] error: std::io::Error,
44 },
45 #[error("failed to load file {path}")]
47 Load {
48 path: std::path::PathBuf,
50 #[source] error: Error,
52 },
53}