mssf_core/runtime/
error.rs1use crate::{HRESULT, WString};
7
8pub fn fill_fabric_hresult(code: HRESULT) -> crate::WinError {
12 let sf_err = crate::API_TABLE.fabric_get_last_error_message().unwrap();
14 let err_str_raw = unsafe { sf_err.get_String() };
15 let err_str = if err_str_raw.is_null() {
16 &[]
17 } else {
18 unsafe { err_str_raw.as_wide() }
19 };
20 println!("debug std: {}", WString::from_wide(err_str));
21 crate::WinError::new(code, WString::from_wide(err_str).to_string())
22}
23
24pub fn fill_fabric_error(e: crate::WinError) -> crate::WinError {
25 fill_fabric_hresult(e.code())
26}
27
28#[cfg(test)]
29#[cfg(windows)] mod test {
31 use crate::{WString, WinError};
32 use mssf_com::FabricTypes::FABRIC_E_GATEWAY_NOT_REACHABLE;
33
34 #[test]
35 fn test_win_error() {
36 let s = WString::from("MyError");
37 let e = WinError::new(
38 crate::HRESULT(FABRIC_E_GATEWAY_NOT_REACHABLE.0),
39 s.clone().to_string(),
40 );
41 assert_eq!(e.message(), s.to_string_lossy());
42 }
43}