alpm_types/package/
error.rs

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