Skip to main content

sqry_core/session/
error.rs

1//! Error types for session management operations.
2
3use std::io;
4use std::path::PathBuf;
5
6use notify::Error as NotifyError;
7use thiserror::Error;
8
9/// Result alias for session operations.
10pub type SessionResult<T> = Result<T, SessionError>;
11
12/// Errors that can occur while managing session state.
13#[derive(Debug, Error)]
14pub enum SessionError {
15    /// Failure to create the underlying filesystem watcher.
16    #[error("failed to create session file watcher: {0}")]
17    WatcherInit(#[from] NotifyError),
18
19    /// Failure to register a workspace index for watching.
20    #[error("failed to watch index file at {path}: {source}")]
21    WatchIndex {
22        /// Workspace path being watched.
23        path: PathBuf,
24        /// Underlying filesystem watcher error.
25        #[source]
26        source: NotifyError,
27    },
28
29    /// Failure to unregister a workspace index path.
30    #[error("failed to unwatch index file at {path}: {source}")]
31    UnwatchIndex {
32        /// Workspace path being un-watched.
33        path: PathBuf,
34        /// Underlying filesystem watcher error.
35        #[source]
36        source: NotifyError,
37    },
38
39    /// Failure to read filesystem metadata for the cached index.
40    #[error("failed to read metadata for {path}: {source}")]
41    IndexMetadata {
42        /// Path to the `.sqry-index` file.
43        path: PathBuf,
44        /// Filesystem error that occurred while reading metadata.
45        #[source]
46        source: io::Error,
47    },
48
49    /// Failure to deserialize a symbol index from disk.
50    #[error("failed to load symbol index from {path}: {source}")]
51    IndexLoad {
52        /// Path to the `.sqry-index` file.
53        path: PathBuf,
54        /// Deserialization error emitted by the symbol index loader.
55        #[source]
56        source: crate::Error,
57    },
58
59    /// Failure to execute a query against a cached index.
60    #[error("failed to execute query: {0}")]
61    QueryExecution(#[source] crate::Error),
62
63    /// Failure to parse a query string.
64    #[error("failed to parse query: {0}")]
65    QueryParse(String),
66
67    /// Failure to spawn the background session maintenance thread.
68    #[error("failed to spawn session maintenance thread: {0}")]
69    SpawnThread(#[source] io::Error),
70}