1use std::{any::Any, path::PathBuf, result};
2
3use thiserror::Error;
4
5use crate::{AnyBoxedError, AnyError};
6
7pub type Result<T> = result::Result<T, Error>;
9
10#[derive(Debug, Error)]
12pub enum Error {
13 #[error("error while checking maildir configuration")]
14 CheckConfigurationInvalidPathError(#[source] shellexpand_utils::Error),
15 #[error("error while checking up current maildir directory")]
16 CheckUpCurrentDirectoryError(#[source] maildirs::Error),
17 #[error("cannot create maildir folder structure at {0}")]
18 CreateFolderStructureError(#[source] maildirs::Error, PathBuf),
19
20 #[error(transparent)]
21 ExpandPathError(#[from] shellexpand_utils::Error),
22 #[error(transparent)]
23 MaildirError(#[from] maildirs::Error),
24}
25
26impl AnyError for Error {
27 fn as_any(&self) -> &dyn Any {
28 self
29 }
30}
31
32impl From<Error> for AnyBoxedError {
33 fn from(err: Error) -> Self {
34 Box::new(err)
35 }
36}