Skip to main content

ephemeris_files/path/
error.rs

1use std::io;
2use std::path::PathBuf;
3
4/// A repository path is malformed, unsafe to use, or cannot be inspected.
5#[derive(Debug, thiserror::Error)]
6pub enum PathError {
7    /// The text is absolute, empty, or contains `.`/`..` segments.
8    #[error("invalid repository-relative path `{path}`")]
9    Invalid {
10        /// The text that failed to parse as a repository-relative path.
11        path: String,
12    },
13    /// The path would fall outside the repository root.
14    #[error("refusing to use a path outside the repository: `{}`", .0.display())]
15    Outside(PathBuf),
16    /// A path that must be a regular file or missing is a symlink.
17    #[error("unsafe symlink path `{}`", .0.display())]
18    Symlink(PathBuf),
19    /// A filesystem operation failed for a specific path.
20    #[error("filesystem error for {}", path.display())]
21    Io {
22        /// The path the operation concerned.
23        path: PathBuf,
24        /// The underlying I/O failure.
25        #[source]
26        source: io::Error,
27    },
28}