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 /// A path represents neither a directory nor a regular file.
11 #[error("The path {path:?} is not a directory or a regular file")]
12 PathIsNotDirOrFile {
13 /// The invalid path.
14 path: PathBuf,
15 },
16
17 /// A user has no default VOA load path.
18 ///
19 /// This usually happens if the user has no `$HOME` assigned to it.
20 #[error("There is no default VOA load path for this user")]
21 NoLoadPath,
22
23 /// A technology is not supported.
24 #[error("The {technology} technology is not (yet) supported")]
25 UnsupportedTechnology {
26 /// The technology that is not supported.
27 technology: Technology,
28 },
29
30 /// An error occurred in VOA-core.
31 #[error("VOA core error:\n{0}")]
32 VoaCore(#[from] voa_core::Error),
33
34 /// An error occurred in VOA-OpenPGP.
35 #[error("VOA OpenPGP error:\n{0}")]
36 VoaOpenPgp(#[from] voa_openpgp::Error),
37
38 /// The JSON serialization of data failed.
39 #[error("JSON serialization error while {context}: {source}")]
40 JsonSerialization {
41 /// The context in which the error occurred.
42 ///
43 /// This is meant to complete the sentence "JSON serialization error while...".
44 context: &'static str,
45
46 /// The error source.
47 source: serde_json::Error,
48 },
49}