windows_lsa/error.rs
1//! Error type.
2
3use thiserror::Error;
4
5pub type Result<T> = core::result::Result<T, Error>;
6
7#[derive(Debug, Error)]
8pub enum Error {
9 /// LSA API returned a non-success NTSTATUS at the transport layer
10 /// (i.e. the `LsaCallAuthenticationPackage` return value itself).
11 #[error("LSA API {api} failed: NTSTATUS 0x{status:08x}")]
12 Lsa { api: &'static str, status: u32 },
13
14 /// `LsaCallAuthenticationPackage` succeeded at the transport level but
15 /// the auth package (Kerberos) reported a protocol-level failure via the
16 /// out-parameter `ProtocolStatus`.
17 #[error("Kerberos package returned protocol error: NTSTATUS 0x{0:08x}")]
18 Protocol(u32),
19
20 /// A response buffer from the auth package was too short or malformed.
21 #[error("response buffer malformed: {0}")]
22 Malformed(&'static str),
23
24 /// String supplied by the caller cannot be encoded into UTF-16 within
25 /// the length constraints of a `UNICODE_STRING` (max 65534 bytes).
26 #[error("string too long for UNICODE_STRING")]
27 StringTooLong,
28
29 /// Numeric overflow when computing a buffer size.
30 #[error("buffer arithmetic overflow")]
31 Overflow,
32
33 /// Called on a non-Windows target. The whole crate is a no-op there.
34 #[error("windows-lsa is only functional on Windows")]
35 Unsupported,
36}