Skip to main content

synwire_core/vfs/
error.rs

1//! VFS error types.
2
3use std::io;
4use thiserror::Error;
5
6/// VFS operation errors.
7#[derive(Error, Debug)]
8#[non_exhaustive]
9pub enum VfsError {
10    /// File or directory not found.
11    #[error("Not found: {0}")]
12    NotFound(String),
13
14    /// Permission denied.
15    #[error("Permission denied: {0}")]
16    PermissionDenied(String),
17
18    /// Expected file, got directory.
19    #[error("Is a directory: {0}")]
20    IsDirectory(String),
21
22    /// Path traversal attempt blocked.
23    #[error("Path traversal blocked: attempted {attempted}, root {root}")]
24    PathTraversal {
25        /// Attempted path.
26        attempted: String,
27        /// Root path.
28        root: String,
29    },
30
31    /// Operation outside allowed scope.
32    #[error("Scope violation: path {path} outside scope {scope}")]
33    ScopeViolation {
34        /// Path that violated scope.
35        path: String,
36        /// Allowed scope.
37        scope: String,
38    },
39
40    /// Resource limit exceeded.
41    #[error("Resource limit: {0}")]
42    ResourceLimit(String),
43
44    /// Operation timed out.
45    #[error("Timeout: {0}")]
46    Timeout(String),
47
48    /// User denied approval.
49    #[error("Operation denied: {0}")]
50    OperationDenied(String),
51
52    /// File was modified externally since last read.  Re-read before editing.
53    #[error(
54        "Stale read: {path} was modified externally since it was last read. Re-read the file before editing."
55    )]
56    StaleRead {
57        /// Path of the stale file.
58        path: String,
59    },
60
61    /// File has not been read yet.  Read before editing.
62    #[error("Not read: {path} must be read before editing or writing. Read the file first.")]
63    NotRead {
64        /// Path that was not read.
65        path: String,
66    },
67
68    /// Indexing denied for safety reasons.
69    #[error("Index denied: {reason}")]
70    IndexDenied {
71        /// Reason for denial.
72        reason: String,
73    },
74
75    /// Index is not ready yet — still building.
76    #[error("Index not ready: {0}")]
77    IndexNotReady(String),
78
79    /// Provider doesn't support operation.
80    #[error("Unsupported: {0}")]
81    Unsupported(String),
82
83    /// I/O error.
84    #[error("I/O error: {0}")]
85    Io(#[from] io::Error),
86}