diff --git a/src/fe/mod.rs b/src/fe/mod.rs index a7a7958..d5d2c7f 100644 --- a/src/fe/mod.rs +++ b/src/fe/mod.rs @@ -82,16 +82,16 @@ impl AsRawFd for FeDevice { #[macro_export] macro_rules! get_dtv_properties { - ( $device:expr, $( $property:ident ),+ ) => { (|| -> anyhow::Result<_> { + ( $device:expr, $( $property:ident ),+ ) => { (|| -> ::anyhow::Result<_> { let mut input = [ $( $property(DtvPropertyRequest::default()), )* ]; - $device.get_properties(&mut input)?; + $device.get_properties(&mut input).context("Error fetching properties")?; let mut iterator = input.iter(); Ok(( $( match iterator.next() { Some($property(d)) => d.get(), - _ => ::anyhow::Result::Err(anyhow!("Error unpacking")), - }?, + _ => ::anyhow::Result::Err(anyhow!("Missing value")), + }.with_context(|| format!("Error unpacking {}", stringify!($property)))?, )* )) })()} diff --git a/src/fe/status.rs b/src/fe/status.rs index df5ce31..2a1d1f6 100644 --- a/src/fe/status.rs +++ b/src/fe/status.rs @@ -2,7 +2,7 @@ use crate::get_dtv_properties; use { super::{sys::*, FeDevice}, - anyhow::Result, + anyhow::{Context, Result}, std::fmt, }; diff --git a/src/fe/sys.rs b/src/fe/sys.rs index bf3efdf..8cd6ed3 100644 --- a/src/fe/sys.rs +++ b/src/fe/sys.rs @@ -868,7 +868,7 @@ macro_rules! dtv_property { #[macro_export] macro_rules! dtv_property_parse { ( $property:ident($data:expr)) => { - $property(DtvPropertyRequest::new($data.parse().context(format!("Invalid {}: {}", stringify!($property), $data))?)) + $property(DtvPropertyRequest::new($data.parse().with_context(||format!("Invalid {}: {}", stringify!($property), $data))?)) }; }