Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NTSTATUS message formatting support to the windows-result crate #2861

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Feb 20, 2024

The HRESULT type supports producing a system error message for HRESULT and Win32 error codes. This update adds support for NTSTATUS error codes as well. HRESULT now also provides a matching from_nt method alongside the existing from_win32. For example:

use windows_result::*;
use windows_sys::Win32::Foundation::*;

fn main() {
    assert_eq!(
        HRESULT(E_INVALIDARG).message(),
        "The parameter is incorrect."
    );
    assert_eq!(
        HRESULT::from_win32(ERROR_CANCELLED).message(),
        "The operation was canceled by the user."
    );
    assert_eq!(
        HRESULT::from_nt(STATUS_NOT_FOUND).message(),
        "The object was not found."
    );
}

@kennykerr kennykerr merged commit 426865a into master Feb 20, 2024
65 checks passed
@kennykerr kennykerr deleted the ntstatus-message branch February 20, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant