voa/error.rs
1//! Error handling.
2
3use std::path::PathBuf;
4
5use voa_core::identifiers::Technology;
6
7/// The error that can occur when using VOA.
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 /// An I/O error occurred at a path.
11 #[error("I/O error at path {path} while {context}:\n{source}")]
12 IoPath {
13 /// The path at which the error occurred.
14 path: PathBuf,
15 /// The context in which the error occurred.
16 ///
17 /// This is meant to complete the sentence "I/O error at path while ".
18 context: &'static str,
19 /// The source error.
20 source: std::io::Error,
21 },
22
23 /// A path is not a regular file.
24 #[error("The path {path:?} is not a regular file")]
25 PathIsNotAFile {
26 /// The invalid path.
27 path: PathBuf,
28 },
29
30 /// A path represents neither a directory nor a regular file.
31 #[error("The path {path:?} is not a directory or a regular file")]
32 PathIsNotDirOrFile {
33 /// The invalid path.
34 path: PathBuf,
35 },
36
37 /// A user has no default VOA load path.
38 ///
39 /// This usually happens if the user has no `$HOME` assigned to it.
40 #[error("There is no default VOA load path for this user")]
41 NoLoadPath,
42
43 /// A technology is not supported.
44 #[error("The {technology} technology is not (yet) supported")]
45 UnsupportedTechnology {
46 /// The technology that is not supported.
47 technology: Technology,
48 },
49
50 /// An error occurred in VOA-core.
51 #[error("VOA core error:\n{0}")]
52 VoaCore(#[from] voa_core::Error),
53
54 /// An error occurred in VOA-OpenPGP.
55 #[error("VOA OpenPGP error:\n{0}")]
56 VoaOpenPgp(#[from] voa_openpgp::Error),
57
58 /// The JSON serialization of data failed.
59 #[error("JSON serialization error while {context}: {source}")]
60 JsonSerialization {
61 /// The context in which the error occurred.
62 ///
63 /// This is meant to complete the sentence "JSON serialization error while...".
64 context: &'static str,
65
66 /// The error source.
67 source: serde_json::Error,
68 },
69
70 /// The verification of one or more signatures failed.
71 #[error("The verification of the following signatures failed: {}", signatures.join(", "))]
72 SignatureVerificationFailed {
73 /// The paths of the failed signatures.
74 signatures: Vec<String>,
75 },
76}