36 lines
757 B
Rust
36 lines
757 B
Rust
use std::sync::{MutexGuard, PoisonError, TryLockError};
|
|
|
|
use derive_more::{Display, From};
|
|
use path::PathHandler;
|
|
|
|
pub type Result<T> = core::result::Result<T, Error>;
|
|
|
|
#[derive(Debug, From, Display)]
|
|
pub enum Error {
|
|
#[from]
|
|
Io(std::io::Error),
|
|
|
|
MutexLock(String),
|
|
|
|
MutexTryLock(String),
|
|
|
|
PathSub,
|
|
|
|
#[from]
|
|
Toml(toml::de::Error),
|
|
|
|
MissingPathHandler,
|
|
}
|
|
|
|
impl From<PoisonError<MutexGuard<'_, PathHandler>>> for Error {
|
|
fn from(value: PoisonError<MutexGuard<PathHandler>>) -> Self {
|
|
Self::MutexLock(value.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<TryLockError<MutexGuard<'_, PathHandler>>> for Error {
|
|
fn from(value: TryLockError<MutexGuard<PathHandler>>) -> Self {
|
|
Self::MutexTryLock(value.to_string())
|
|
}
|
|
}
|