alpm_pkginfo/
error.rs

1use std::{path::PathBuf, string::FromUtf8Error};
2
3/// The Error that can occur when working with PKGINFO files
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7    /// ALPM type error
8    #[error("ALPM type parse error: {0}")]
9    AlpmType(#[from] alpm_types::Error),
10
11    /// IO error
12    #[error("I/O error at path {0:?} while {1}:\n{2}")]
13    IoPathError(PathBuf, &'static str, std::io::Error),
14
15    /// I/O error while reading a buffer.
16    #[error("Read error while {context}:\n{source}")]
17    IoReadError {
18        context: &'static str,
19        source: std::io::Error,
20    },
21
22    /// UTF-8 parse error
23    #[error(transparent)]
24    InvalidUTF8(#[from] FromUtf8Error),
25
26    // Deserialize error
27    #[error("Failed to deserialize PKGINFO file:\n{0}")]
28    DeserializeError(#[from] alpm_parsers::custom_ini::Error),
29
30    /// An extra data field specified without any value.
31    #[error("Extra data field is specified without any value")]
32    ExtraDataEmpty,
33
34    /// The first extra data field does not specify "pkgtype".
35    #[error("The first extra data definition does not specify \"pkgtype\"")]
36    FirstExtraDataNotPkgType,
37
38    /// No input file given
39    #[error("No input file given.")]
40    NoInputFile,
41
42    /// JSON error
43    #[error("JSON error: {0}")]
44    Json(#[from] serde_json::Error),
45
46    /// An invalid enum variant
47    #[error("Invalid variant ({0})")]
48    InvalidVariant(#[from] strum::ParseError),
49
50    /// Extra data is missing
51    #[error("Extra data is missing.")]
52    MissingExtraData,
53
54    /// Unsupported schema version
55    #[error("Unsupported schema version: {0}")]
56    UnsupportedSchemaVersion(String),
57}