Skip to main content

fff_search/
error.rs

1use std::path::StripPrefixError;
2
3#[derive(thiserror::Error, Debug)]
4#[non_exhaustive]
5pub enum Error {
6    #[error("Thread panicked")]
7    ThreadPanic,
8    #[error("Invalid path {0}")]
9    InvalidPath(std::path::PathBuf),
10    #[error("File picker not initialized")]
11    FilePickerMissing,
12    #[error("Failed to acquire lock for frecency")]
13    AcquireFrecencyLock,
14    #[error("Failed to acquire lock for items by provider")]
15    AcquireItemLock,
16    #[error("Failed to acquire lock for path cache")]
17    AcquirePathCacheLock,
18    #[error("Failed to create directory: {0}")]
19    CreateDir(#[from] std::io::Error),
20    #[error("Failed to open frecency database env: {0}")]
21    EnvOpen(#[source] heed::Error),
22    #[error("Failed to create frecency database: {0}")]
23    DbCreate(#[source] heed::Error),
24    #[error("Failed to clear stale readers for frecency database: {0}")]
25    DbClearStaleReaders(#[source] heed::Error),
26
27    #[error("Failed to start read transaction for frecency database: {0}")]
28    DbStartReadTxn(#[source] heed::Error),
29    #[error("Failed to start write transaction for frecency database: {0}")]
30    DbStartWriteTxn(#[source] heed::Error),
31
32    #[error("Failed to read from frecency database: {0}")]
33    DbRead(#[source] heed::Error),
34    #[error("Failed to write to frecency database: {0}")]
35    DbWrite(#[source] heed::Error),
36    #[error("Failed to commit write transaction to frecency database: {0}")]
37    DbCommit(#[source] heed::Error),
38    #[error("Failed to start file system watcher: {0}")]
39    FileSystemWatch(#[from] notify::Error),
40
41    #[error("Expected a path to be child of another path: {0}")]
42    StripPrefixError(#[from] StripPrefixError),
43
44    #[error("libgit2 error occurred: {0}")]
45    Git(#[from] git2::Error),
46}
47
48pub type Result<T> = std::result::Result<T, Error>;