use advisory_lock::FileLockError;
use std::{io, path::PathBuf, result};
use thiserror::Error;
use crate::{email, folder, thread_pool};
pub type Result<T> = result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("cannot open sync lock file at {1}")]
OpenLockFileError(#[source] io::Error, PathBuf),
#[error("cannot lock sync file at {1}")]
LockFileError(#[source] FileLockError, PathBuf),
#[error("cannot unlock sync file at {1}")]
UnlockFileError(#[source] FileLockError, PathBuf),
#[error("cannot get sync cache directory")]
GetCacheDirectorySyncError,
#[error("cannot build sync thread pool")]
BuildThreadPoolError(#[source] thread_pool::Error),
#[error("cannot sync folders")]
SyncFoldersError(#[source] folder::Error),
#[error("cannot expunge folders after sync")]
ExpungeFoldersError(#[source] folder::Error),
#[error("cannot sync emails")]
SyncEmailsError(#[source] email::Error),
}