mirror of
https://github.com/danog/libdvb.git
synced 2024-11-26 20:04:39 +01:00
More and better context
This commit is contained in:
parent
a33cd90986
commit
086d025e00
@ -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)))?,
|
||||
)*
|
||||
))
|
||||
})()}
|
||||
|
@ -2,7 +2,7 @@ use crate::get_dtv_properties;
|
||||
|
||||
use {
|
||||
super::{sys::*, FeDevice},
|
||||
anyhow::Result,
|
||||
anyhow::{Context, Result},
|
||||
std::fmt,
|
||||
};
|
||||
|
||||
|
@ -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))?))
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user