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(
11        "Can not run certain FFF features in a file system root or home directories. Consider smaller per-project directories."
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("Something is wrong with the local db instance: {0}")]
30    GenericDbError(#[from] heed::Error),
31    #[error("Failed to open {db} database env: {source}")]
32    EnvOpen {
33        db: &'static str,
34        #[source]
35        source: heed::Error,
36    },
37    #[error("Failed to create {db} database: {source}")]
38    DbCreate {
39        db: &'static str,
40        #[source]
41        source: heed::Error,
42    },
43    #[error("Failed to open {db} database: {source}")]
44    DbOpen {
45        db: &'static str,
46        #[source]
47        source: heed::Error,
48    },
49    #[error("Failed to clear stale readers for {db} database: {source}")]
50    DbClearStaleReaders {
51        db: &'static str,
52        #[source]
53        source: heed::Error,
54    },
55
56    #[error("Failed to start read transaction for {db} database: {source}")]
57    DbStartReadTxn {
58        db: &'static str,
59        #[source]
60        source: heed::Error,
61    },
62    #[error("Failed to start write transaction for {db} database: {source}")]
63    DbStartWriteTxn {
64        db: &'static str,
65        #[source]
66        source: heed::Error,
67    },
68    #[error("Failed to read from {db} database: {source}")]
69    DbRead {
70        db: &'static str,
71        #[source]
72        source: heed::Error,
73    },
74    #[error("Failed to write to {db} database: {source}")]
75    DbWrite {
76        db: &'static str,
77        #[source]
78        source: heed::Error,
79    },
80    #[error("Failed to commit write transaction to {db} database: {source}")]
81    DbCommit {
82        db: &'static str,
83        #[source]
84        source: heed::Error,
85    },
86    #[error("Failed to start file system watcher: {0}")]
87    FileSystemWatch(#[from] notify::Error),
88
89    #[error("Expected a path to be child of another path: {0}")]
90    StripPrefixError(#[from] StripPrefixError),
91
92    #[error("libgit2 error occurred: {0}")]
93    Git(#[from] git2::Error),
94}
95
96pub type Result<T> = std::result::Result<T, Error>;