alpm_buildinfo/
error.rs

1use std::{path::PathBuf, string::FromUtf8Error};
2
3use alpm_types::SchemaVersion;
4
5/// The Error that can occur when working with BUILDINFO files
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9    /// ALPM type error
10    #[error("ALPM type parse error: {0}")]
11    AlpmType(#[from] alpm_types::Error),
12
13    /// IO error
14    #[error("I/O error at path {0:?} while {1}:\n{2}")]
15    IoPathError(PathBuf, &'static str, std::io::Error),
16
17    /// I/O error while reading a buffer.
18    #[error("Read error while {context}:\n{source}")]
19    IoReadError {
20        /// The context in which the error occurred.
21        ///
22        /// This is meant to complete the sentence "Read error while ".
23        context: &'static str,
24        /// The error source.
25        source: std::io::Error,
26    },
27
28    /// UTF-8 parse error
29    #[error(transparent)]
30    InvalidUTF8(#[from] FromUtf8Error),
31
32    /// An [`alpm_parsers::custom_ini::Error`].
33    #[error("Failed to deserialize BUILDINFO file:\n{0}")]
34    DeserializeError(#[from] alpm_parsers::custom_ini::Error),
35
36    /// No input file given
37    #[error("No input file given.")]
38    NoInputFile,
39
40    /// Unsupported schema version
41    #[error("Unsupported schema version: {0}")]
42    UnsupportedSchemaVersion(String),
43
44    /// A SchemaVersion with the wrong version is used
45    #[error("Wrong schema version used to create a BUILDINFO: {0}")]
46    WrongSchemaVersion(SchemaVersion),
47
48    /// BuildInfo file is missing the format field
49    #[error("Missing format field")]
50    MissingFormatField,
51
52    /// JSON error
53    #[error("JSON error: {0}")]
54    Json(#[from] serde_json::Error),
55}