[go: up one dir, main page]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
use failure::Fail;
use winapi::shared::ntdef::HRESULT;

#[derive(Debug, Fail)]
pub enum WMIError {
    #[fail(display = "HRESULT Call failed with: {:#X}", hres)]
    HResultError { hres: HRESULT },
}

pub fn check_hres(hres: HRESULT) -> Result<(), WMIError> {
    if hres < 0 {
        return Err(WMIError::HResultError { hres });
    }

    Ok(())
}