1use std::{path::PathBuf, string::FromUtf8Error};
3
4use alpm_pkgbuild::error::Error as PkgbuildError;
5use fluent_i18n::t;
6use thiserror::Error;
7
8use crate::pkgbuild_bridge::error::BridgeError;
9#[cfg(doc)]
10use crate::{SourceInfoV1, source_info::parser::SourceInfoContent};
11
12#[derive(Debug, Error)]
18#[non_exhaustive]
19pub enum Error {
20 #[error("{msg}", msg = t!("error-alpm-type", { "error" => .0.to_string() }))]
22 AlpmType(#[from] alpm_types::Error),
23
24 #[error("{msg}", msg = t!("error-io", { "context" => .context, "error" => .source.to_string() }))]
26 Io {
27 context: String,
29 source: std::io::Error,
31 },
32
33 #[error("{msg}", msg = t!("error-io-path", {
35 "path" => path,
36 "context" => context,
37 "error" => source.to_string()
38 }))]
39 IoPath {
40 path: PathBuf,
42 context: String,
44 source: std::io::Error,
46 },
47
48 #[error("{msg}", msg = t!("error-invalid-utf8", { "error" => .0.to_string() }))]
50 InvalidUTF8(#[from] FromUtf8Error),
51
52 #[error("{msg}", msg = t!("error-missing-keyword", { "keyword" => keyword }))]
54 MissingKeyword {
55 keyword: &'static str,
57 },
58
59 #[error("{msg}", msg = t!("error-parse", { "error" => .0 }))]
61 ParseError(String),
62
63 #[error("{msg}", msg = t!("error-unsupported-schema-version", { "version" => .0 }))]
65 UnsupportedSchemaVersion(String),
66
67 #[error("{msg}", msg = t!("error-bridge", { "error" => .0.to_string() }))]
71 BridgeError(#[from] PkgbuildError),
72
73 #[error("{msg}", msg = t!("error-bridge-conversion", { "error" => .0.to_string() }))]
78 BridgeConversionError(#[from] BridgeError),
79}