get-last-error

CI crates.io Documentation dependency status MIT

An error wrapper over Win32 API errors.

Examples

A Win32Error can be constructed from an arbitrary DWORD:

```rust use getlasterror::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:

```rust use getlasterror::Win32Error; use winapi::um::{winnt::HANDLE, processthreadsapi::OpenProcess};

fn openprocess() -> Result { let result = unsafe { OpenProcess(0, 0, 0) }; // some windows api call if result.isnull() { // null indicates failure. Err(Win32Error::getlasterror()) } else { Ok(result) } } ```

License

Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)