Many errors should hold an `std::io::Error::last_os_error()`
Today majority of pipewire-rs
methods return a pipewire::Error
which is comparatively simple:
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Creation failed")]
CreationFailed,
#[error("No memory")]
NoMemory,
#[error("Wrong proxy type")]
WrongProxyType,
#[error(transparent)]
SpaError(#[from] spa::Error),
}
This discards a fair amount of useful information about an issue which can make figuring out issues much more difficult. In particular it appears that the upstream pipewire
project relies on errno
as a mechanism to return information about why some operations might have failed. So, for example, if Context::connect
is invoked when the daemon is not running you would get a Creation failed
while a much more precise Host is down (os error 112)
is possible.
Perhaps a better way to structure these errors would be to straight up return a std::io::Error
from some of the wrappers, or perhaps to change the Error
type so it reads more like:
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
CreationFailed(#[source] std::io::Error),
// ...
}