alpm_common/
error.rs

1use std::path::{PathBuf, StripPrefixError};
2
3/// An error that can occur when dealing with package inputs.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// An I/O error occurred at a path.
7    #[error("I/O error at path {path} while {context}:\n{source}")]
8    IoPath {
9        /// The path at which the error occurred.
10        path: PathBuf,
11        /// The context in which the error occurred.
12        ///
13        /// This is meant to complete the sentence "I/O error at path while ".
14        context: &'static str,
15        /// The source error.
16        source: std::io::Error,
17    },
18
19    /// A path's prefix cannot be stripped.
20    #[error("Cannot strip prefix {prefix} from path {path}:\n{source}")]
21    PathStripPrefix {
22        /// The prefix that is supposed to be stripped from `path`.
23        prefix: PathBuf,
24        /// The path that is supposed to stripped.
25        path: PathBuf,
26        /// The source error.
27        source: StripPrefixError,
28    },
29}