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(
11 "Can not start fff at the file system root {0} — pass a project or at least home directory instead"
12 )]
13 FilesystemRoot(std::path::PathBuf),
14 #[error("File picker not initialized")]
15 FilePickerMissing,
16 #[error("Failed to acquire lock for frecency")]
17 AcquireFrecencyLock,
18 #[error("Failed to acquire lock for items by provider")]
19 AcquireItemLock,
20 #[error("Failed to acquire lock for path cache")]
21 AcquirePathCacheLock,
22 #[error("Failed to create directory: {0}")]
23 CreateDir(#[from] std::io::Error),
24 #[error("Failed to remove database directory {path}: {source}")]
25 RemoveDbDir {
26 path: std::path::PathBuf,
27 source: std::io::Error,
28 },
29 #[error("Failed to open frecency database env: {0}")]
30 EnvOpen(#[source] heed::Error),
31 #[error("Failed to create frecency database: {0}")]
32 DbCreate(#[source] heed::Error),
33 #[error("Failed to open frecency database: {0}")]
34 DbOpen(#[source] heed::Error),
35 #[error("Failed to clear stale readers for frecency database: {0}")]
36 DbClearStaleReaders(#[source] heed::Error),
37
38 #[error("Failed to start read transaction for frecency database: {0}")]
39 DbStartReadTxn(#[source] heed::Error),
40 #[error("Failed to start write transaction for frecency database: {0}")]
41 DbStartWriteTxn(#[source] heed::Error),
42
43 #[error("Failed to read from frecency database: {0}")]
44 DbRead(#[source] heed::Error),
45 #[error("Failed to write to frecency database: {0}")]
46 DbWrite(#[source] heed::Error),
47 #[error("Failed to commit write transaction to frecency database: {0}")]
48 DbCommit(#[source] heed::Error),
49 #[error("Failed to start file system watcher: {0}")]
50 FileSystemWatch(#[from] notify::Error),
51
52 #[error("Expected a path to be child of another path: {0}")]
53 StripPrefixError(#[from] StripPrefixError),
54
55 #[error("libgit2 error occurred: {0}")]
56 Git(#[from] git2::Error),
57}
58
59pub type Result<T> = std::result::Result<T, Error>;