alpm_soname/error.rs
1//! Error handling.
2
3use std::path::PathBuf;
4
5use fluent_i18n::t;
6
7/// The error that can occur when working with the library.
8#[derive(Debug, thiserror::Error)]
9#[non_exhaustive]
10pub enum Error {
11 /// I/O path error
12 #[error("{msg}", msg = t!("error-io-path-error", {
13 "path" => path,
14 "context" => context,
15 "source" => source.to_string()
16 }))]
17 IoPath {
18 /// The path at which the error occurred.
19 path: PathBuf,
20
21 /// The context in which the error occurred at `path`.
22 ///
23 /// This is meant to complete the sentence "I/O error at path {path} while ".
24 context: String,
25
26 /// The source of the error.
27 source: std::io::Error,
28 },
29
30 /// I/O error while writing.
31 #[error("{msg}", msg = t!("error-io-write-error", {
32 "context" => context,
33 "source" => source.to_string()
34 }))]
35 IoWrite {
36 /// The context in which the error occurred.
37 ///
38 /// This is meant to complete the sentence "I/O write error while ".
39 context: String,
40
41 /// The source of the error.
42 source: std::io::Error,
43 },
44
45 /// I/O error while reading.
46 #[error("{msg}", msg = t!("error-io-read-error", {
47 "context" => context,
48 "source" => source.to_string()
49 }))]
50 IoRead {
51 /// The context in which the error occurred.
52 ///
53 /// This is meant to complete the sentence "I/O read error while ".
54 context: String,
55
56 /// The source of the error.
57 source: std::io::Error,
58 },
59
60 /// ALPM PKGINFO error
61 #[error(transparent)]
62 AlpmPkginfo(#[from] alpm_pkginfo::Error),
63
64 /// ALPM types error
65 #[error(transparent)]
66 AlpmType(#[from] alpm_types::Error),
67
68 /// ALPM package error
69 #[error(transparent)]
70 AlpmPackage(#[from] alpm_package::Error),
71
72 /// ELF format handling error
73 #[error("{msg}", msg = t!("error-elf-error", {
74 "context" => context,
75 "source" => source.to_string()
76 }))]
77 Elf {
78 /// The context in which the error occurred.
79 ///
80 /// This is meant to complete the sentence "ELF format error while ".
81 context: String,
82
83 /// The source of the error.
84 source: goblin::error::Error,
85 },
86
87 /// ELF not found error
88 #[error("{msg}", msg = t!("error-elf-file-not-found", { "elf_path" => elf_path }))]
89 ElfFileNotFound {
90 /// Path of the ELF file specified by the user.
91 elf_path: PathBuf,
92 },
93
94 /// Input directory not supported
95 #[error("{msg}", msg = t!("error-input-dir-not-supported", { "path" => path }))]
96 InputDirectoryNotSupported {
97 /// The path of the input directory.
98 path: PathBuf,
99 },
100}