sl4f_lib/common_utils/
error.rsuse fidl_fuchsia_bluetooth as bt;
use thiserror::Error;
#[derive(Debug, Error)]
#[error("{}", message)]
pub struct Sl4fError {
message: String,
}
impl Sl4fError {
pub fn new(msg: &str) -> Sl4fError {
Sl4fError { message: msg.to_string() }
}
}
impl From<bt::Error> for Sl4fError {
fn from(err: bt::Error) -> Sl4fError {
Sl4fError {
message: match err.description {
Some(d) => d,
None => "unknown Bluetooth FIDL error".to_string(),
},
}
}
}
impl From<fidl::Error> for Sl4fError {
fn from(err: fidl::Error) -> Sl4fError {
Sl4fError { message: format!("FIDL error: {}", err) }
}
}