1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use alloc::string::{String, ToString};
use reth_fs_util::FsPathError;

/// Storage lock error.
#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
pub enum StorageLockError {
    /// Write lock taken
    #[display("storage directory is currently in use as read-write by another process: PID {_0}")]
    Taken(usize),
    /// Indicates other unspecified errors.
    #[display("{_0}")]
    Other(String),
}

#[cfg(feature = "std")]
impl std::error::Error for StorageLockError {}

/// TODO: turn into variant once `ProviderError`
impl From<FsPathError> for StorageLockError {
    fn from(error: FsPathError) -> Self {
        Self::Other(error.to_string())
    }
}