alpm_types/package/
error.rs

1//! Errors related to package sources, contents and files.
2
3use std::path::PathBuf;
4
5use crate::Version;
6#[cfg(doc)]
7use crate::{MetadataFileName, PackageFileName};
8
9/// The error that can occur when handling types related to package data.
10#[derive(Debug, thiserror::Error, PartialEq)]
11pub enum Error {
12    /// A string is not a valid [`MetadataFileName`].
13    #[error("Invalid package metadata file name: {name}")]
14    InvalidMetadataFilename {
15        /// The invalid file name.
16        name: String,
17    },
18
19    /// A path is not a valid [`PackageFileName`].
20    #[error("The path {path:?} is not a valid alpm-package file name")]
21    InvalidPackageFileNamePath {
22        /// The file path that is not valid.
23        path: PathBuf,
24    },
25
26    /// A path is not a valid [`PackageFileName`].
27    #[error("The version \"{version}\" is not valid for an alpm-package file name")]
28    InvalidPackageFileNameVersion {
29        /// The version that is not valid.
30        version: Version,
31    },
32}