1 use crate::Region; 2 use thiserror::Error; 3 4 #[derive(Debug, Error, PartialEq, Eq)] 5 pub 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("Slice length mismatch")] 17 SliceLengthsDiffer, 18 #[error("In func {modulename}::{funcname} at {location}: {err}")] 19 InFunc { 20 modulename: &'static str, 21 funcname: &'static str, 22 location: &'static str, 23 #[source] 24 err: Box<GuestError>, 25 }, 26 #[error("Invalid UTF-8 encountered: {0:?}")] 27 InvalidUtf8(#[from] ::std::str::Utf8Error), 28 #[error("Int conversion error: {0:?}")] 29 TryFromIntError(#[from] ::std::num::TryFromIntError), 30 } 31