pub struct ThreadErrorMode(/* private fields */);Expand description
Implementations§
Source§impl ThreadErrorMode
impl ThreadErrorMode
Sourcepub const FAIL_CRITICAL_ERRORS: Self
pub const FAIL_CRITICAL_ERRORS: Self
Fail calls that hit a critical error instead of raising a dialog.
Sourcepub const NO_GP_FAULT_ERROR_BOX: Self
pub const NO_GP_FAULT_ERROR_BOX: Self
Suppress the general-protection-fault error box.
Sourcepub const NO_OPEN_FILE_ERROR_BOX: Self
pub const NO_OPEN_FILE_ERROR_BOX: Self
Suppress the file-open error box.
Sourcepub const fn from_bits(bits: THREAD_ERROR_MODE) -> Result<Self, UnsupportedBits>
pub const fn from_bits(bits: THREAD_ERROR_MODE) -> Result<Self, UnsupportedBits>
Build a mode from a raw value.
§Errors
Returns UnsupportedBits if bits contains anything
SetThreadErrorMode does not accept. This is a rejection rather than a
mask: silently dropping a bit would report installing a value that was
not installed, which is the failure this type exists to prevent.
§Example
use windows_thread_ambient_sys::ThreadErrorMode;
assert_eq!(
ThreadErrorMode::from_bits(0x0001),
Ok(ThreadErrorMode::FAIL_CRITICAL_ERRORS)
);
// 0x0004 is SEM_NOALIGNMENTFAULTEXCEPT, which cannot be set per thread.
// It is refused even beside a valid bit, because Windows would install
// neither: an invalid bit fails the whole call.
let refused = ThreadErrorMode::from_bits(0x0001 | 0x0004)
.expect_err("the alignment bit is not settable per thread");
assert_eq!(refused.bits(), 0x0004);Sourcepub fn capture() -> Result<Self, UnsupportedBits>
pub fn capture() -> Result<Self, UnsupportedBits>
Read the calling thread’s current mode.
§Errors
Returns UnsupportedBits if Windows reports a bit this type cannot
hold. Measured, that does not happen: the thread error mode is
independent storage rather than a view of the process error mode, so a
process-scope bit such as SEM_NOALIGNMENTFAULTEXCEPT does not show
through here. The result is still surfaced rather than assumed away,
because a type unable to represent a state the platform can produce would
be a bug, and this is where that would first be observable.
Sourcepub fn apply(self) -> Result<ErrorModeGuard, ApplyError>
pub fn apply(self) -> Result<ErrorModeGuard, ApplyError>
Install this mode on the calling thread until the guard is released.
§Errors
Returns ApplyError if Windows refuses the value, in which case
nothing was installed and the thread is untouched.
Trait Implementations§
Source§impl Clone for ThreadErrorMode
impl Clone for ThreadErrorMode
Source§fn clone(&self) -> ThreadErrorMode
fn clone(&self) -> ThreadErrorMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more