use crate::{HRESULT, WString};
pub fn fill_fabric_hresult(code: HRESULT) -> crate::WinError {
let sf_err = crate::API_TABLE.fabric_get_last_error_message().unwrap();
let err_str_raw = unsafe { sf_err.get_String() };
let err_str = if err_str_raw.is_null() {
&[]
} else {
unsafe { err_str_raw.as_wide() }
};
println!("debug std: {}", WString::from_wide(err_str));
crate::WinError::new(code, WString::from_wide(err_str).to_string())
}
pub fn fill_fabric_error(e: crate::WinError) -> crate::WinError {
fill_fabric_hresult(e.code())
}
#[cfg(test)]
#[cfg(windows)] mod test {
use crate::{WString, WinError};
use mssf_com::FabricTypes::FABRIC_E_GATEWAY_NOT_REACHABLE;
#[test]
fn test_win_error() {
let s = WString::from("MyError");
let e = WinError::new(
crate::HRESULT(FABRIC_E_GATEWAY_NOT_REACHABLE.0),
s.clone().to_string(),
);
assert_eq!(e.message(), s.to_string_lossy());
}
}