Crate get_last_error
source · [−]Expand description
get-last-error
An error wrapper over Win32 API errors.
Examples
A Win32Error can be constructed from an arbitrary DWORD:
use get_last_error::Win32Error;
let err = Win32Error::new(0);
println!("{}", err); // prints "The operation completed successfully."The Win32Error::get_last_error retrieves the last error code for the current thread:
use get_last_error::Win32Error;
use winapi::um::{winnt::HANDLE, processthreadsapi::OpenProcess};
fn open_process() -> Result<HANDLE, Win32Error> {
let result = unsafe { OpenProcess(0, 0, 0) }; // some windows api call
if result.is_null() { // null indicates failure.
Err(Win32Error::get_last_error())
} else {
Ok(result)
}
}Structs
Error when converting a io::Error to a Win32Error when no raw os error code is available.
A wrapper over Win32 API errors.
Implements Display using FormatMessageW.