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 affected file inside `<workspace>/.sqry/graph/`
43        /// (typically `snapshot.sqry` or `manifest.json`).
44        path: PathBuf,
45        /// Filesystem error that occurred while reading metadata.
46        #[source]
47        source: io::Error,
48    },
49
50    /// Failure to deserialize a symbol index from disk.
51    #[error("failed to load symbol index from {path}: {source}")]
52    IndexLoad {
53        /// Path to the snapshot file
54        /// (`<workspace>/.sqry/graph/snapshot.sqry`) that failed to load.
55        path: PathBuf,
56        /// Deserialization error emitted by the symbol index loader.
57        #[source]
58        source: crate::Error,
59    },
60
61    /// Failure to execute a query against a cached index.
62    #[error("failed to execute query: {0}")]
63    QueryExecution(#[source] crate::Error),
64
65    /// Failure to parse a query string.
66    #[error("failed to parse query: {0}")]
67    QueryParse(String),
68
69    /// Failure to spawn the background session maintenance thread.
70    #[error("failed to spawn session maintenance thread: {0}")]
71    SpawnThread(#[source] io::Error),
72}