1#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 #[error("Invalid enum variant: {got}, expected something in {expected:?}")]
8 InvalidEnum {
9 got: String,
10 expected: &'static [&'static str],
11 },
12
13 #[error("Tried to convert Value::{wanted}, but it was {actual:?}")]
15 IncorrectValue {
16 wanted: &'static str,
17 actual: zvariant::OwnedValue,
18 },
19
20 #[error("Failed to parse as a timestamp")]
21 InvalidTimestamp(#[from] jiff::Error),
22
23 #[error("zbus error: {0}")]
25 Zbus(zbus::Error),
26
27 #[error("zbus fdo error: {0}")]
29 Fdo(zbus::fdo::Error),
30}
31
32impl From<zbus::fdo::Error> for Error {
33 fn from(err: zbus::fdo::Error) -> Self {
34 match err {
35 zbus::fdo::Error::ZBus(err) => Self::Zbus(err),
36 _ => Self::Fdo(err),
37 }
38 }
39}
40
41impl From<zbus::Error> for Error {
42 fn from(err: zbus::Error) -> Self {
43 match err {
44 zbus::Error::FDO(err) => Self::Fdo(*err),
45 _ => Self::Zbus(err),
46 }
47 }
48}
49
50impl From<Error> for zvariant::Error {
51 fn from(err: Error) -> Self {
52 Self::Message(err.to_string())
53 }
54}
55
56pub type Result<T> = std::result::Result<T, Error>;