wiggle/
error.rs

1use crate::Region;
2use thiserror::Error;
3
4#[derive(Debug, Error, PartialEq, Eq)]
5pub enum GuestError {
6    #[error("Invalid flag value {0}")]
7    InvalidFlagValue(&'static str),
8    #[error("Invalid enum value {0}")]
9    InvalidEnumValue(&'static str),
10    #[error("Pointer overflow")]
11    PtrOverflow,
12    #[error("Pointer out of bounds: {0:?}")]
13    PtrOutOfBounds(Region),
14    #[error("Pointer not aligned to {1}: {0:?}")]
15    PtrNotAligned(Region, u32),
16    #[error("Pointer already borrowed: {0:?}")]
17    PtrBorrowed(Region),
18    #[error("Borrow checker out of handles")]
19    BorrowCheckerOutOfHandles,
20    #[error("Slice length mismatch")]
21    SliceLengthsDiffer,
22    #[error("In func {modulename}::{funcname} at {location}: {err}")]
23    InFunc {
24        modulename: &'static str,
25        funcname: &'static str,
26        location: &'static str,
27        #[source]
28        err: Box<GuestError>,
29    },
30    #[error("Invalid UTF-8 encountered: {0:?}")]
31    InvalidUtf8(#[from] ::std::str::Utf8Error),
32    #[error("Int conversion error: {0:?}")]
33    TryFromIntError(#[from] ::std::num::TryFromIntError),
34}