//! Lets you actually get error information from Windows.
use super::*;
use winapi::um::errhandlingapi::{GetLastError, SetLastError};
/// The calling thread's last-error code.
///
/// See [`GetLastError`](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror)
#[inline(always)]
pub fn get_last_error() -> ErrorCode {
ErrorCode(unsafe { GetLastError() })
}
/// Sets the calling thread's last-error code.
///
/// See [`SetLastError`](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-setlasterror)
#[inline(always)]
pub fn set_last_error(error: ErrorCode) {
unsafe { SetLastError(error.0) }
}