1#[repr(u32)]
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub enum ExceptionCode {
10 Invalid = 0x0,
11 AccessViolation = 0xC0000005,
12 ArrayBoundsExceeded = 0xC000008C,
13 Breakpoint = 0x80000003,
14 DataTypeMisalignment = 0x80000002,
15 FltDenormalOperand = 0xC000008D,
16 FltDivideByZero = 0xC000008E,
17 FltInexactResult = 0xC000008F,
18 FltInvalidOperation = 0xC0000090,
19 FltOverflow = 0xC0000091,
20 FltStackCheck = 0xC0000092,
21 FltUnderflow = 0xC0000093,
22 GuardPage = 0x80000001,
23 IllegalInstruction = 0xC000001D,
24 InPageError = 0xC0000006,
25 IntDivideByZero = 0xC0000094,
26 IntOverflow = 0xC0000095,
27 InvalidDisposition = 0xC0000026,
28 InvalidHandle = 0xC0000008,
29 NonContinuableException = 0xC0000025,
30 PrivilegedInstruction = 0xC0000096,
31 SingleStep = 0x80000004,
32 StackOverflow = 0xC00000FD,
33 UnwindConsolidate = 0x80000029,
34}
35
36impl core::fmt::Display for ExceptionCode {
37 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47 match self {
48 ExceptionCode::Invalid => write!(f, "invalid exception"),
49 ExceptionCode::AccessViolation => write!(f, "the thread attempts to read from or write to a virtual address for which it does not have access"),
50 ExceptionCode::ArrayBoundsExceeded => write!(f, "the thread attempts to access an array element that is out of bounds and the underlying hardware supports bounds checking"),
51 ExceptionCode::Breakpoint => write!(f, "a breakpoint was encountered"),
52 ExceptionCode::DataTypeMisalignment => write!(f, "the thread attempts to read or write data that is misaligned on hardware that does not provide alignment"),
53 ExceptionCode::FltDenormalOperand => write!(f, "one of the operands in a floating point operation is denormal"),
54 ExceptionCode::FltDivideByZero => write!(f, "the thread attempts to divide a floating point value by a floating point divisor of 0"),
55 ExceptionCode::FltInexactResult => write!(f, "the result of a floating point operation cannot be represented exactly as a decimal fraction"),
56 ExceptionCode::FltInvalidOperation => write!(f, "this exception represents any floating point exception not included in this list"),
57 ExceptionCode::FltOverflow => write!(f, "the exponent of a floating point operation is greater than the magnitude allowed by the corresponding type"),
58 ExceptionCode::FltStackCheck => write!(f, "the stack has overflowed or underflowed, because of a floating point operation"),
59 ExceptionCode::FltUnderflow => write!(f, "the exponent of a floating point operation is less than the magnitude allowed by the corresponding type"),
60 ExceptionCode::GuardPage => write!(f, "the thread accessed memory allocated with the PAGE_GUARD modifier"),
61 ExceptionCode::IllegalInstruction => write!(f, "the thread tries to execute an invalid instruction"),
62 ExceptionCode::InPageError => write!(f, "the thread tries to access a page that is not present, and the system is unable to load the page"),
63 ExceptionCode::IntDivideByZero => write!(f, "the thread attempts to divide an integer value by an integer divisor of 0"),
64 ExceptionCode::IntOverflow => write!(f, "the result of an integer operation creates a value that is too large to be held by the destination register"),
65 ExceptionCode::InvalidDisposition => write!(f, "an exception handler returns an invalid disposition to the exception dispatcher"),
66 ExceptionCode::InvalidHandle => write!(f, "the thread used a handle to a kernel object that was invalid"),
67 ExceptionCode::NonContinuableException => write!(f, "the thread attempts to continue execution after a non-continuable exception occurs"),
68 ExceptionCode::PrivilegedInstruction => write!(f, "the thread attempts to execute an instruction with an operation that is not allowed in the current computer mode"),
69 ExceptionCode::SingleStep => write!(f, "a trace trap or other single instruction mechanism signals that one instruction is executed"),
70 ExceptionCode::StackOverflow => write!(f, "the thread used up its stack"),
71 ExceptionCode::UnwindConsolidate => write!(f, "a frame consolidation has been executed")
72 }
73 }
74}