ephemeris_report/
error.rs1use std::error::Error;
2use std::io;
3use std::path::PathBuf;
4use std::str::Utf8Error;
5
6use facet_json::DeserializeError;
7
8#[derive(Debug, thiserror::Error)]
10pub enum ReportError {
11 #[error("cannot access {}", path.display())]
13 Io {
14 path: PathBuf,
16 #[source]
18 source: io::Error,
19 },
20 #[error("cannot encode the report")]
22 Encode {
23 #[source]
25 source: Box<dyn Error + Send + Sync>,
26 },
27 #[error("cannot decode {}", path.display())]
29 Decode {
30 path: PathBuf,
32 #[source]
34 source: Box<DeserializeError>,
35 },
36}
37
38impl ReportError {
39 pub(crate) fn io(path: impl Into<PathBuf>, source: io::Error) -> Self {
40 Self::Io {
41 path: path.into(),
42 source,
43 }
44 }
45}
46
47#[derive(Debug, thiserror::Error)]
49pub enum ConvertError {
50 #[error("the output is not valid UTF-8")]
52 Utf8(#[from] Utf8Error),
53 #[error("the output is not valid XML")]
55 Xml {
56 #[source]
58 source: roxmltree::Error,
59 },
60 #[error("line {line} is not a valid message")]
62 Json {
63 line: usize,
65 #[source]
67 source: Box<DeserializeError>,
68 },
69}