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("Slice length mismatch")]
19 SliceLengthsDiffer,
20 #[error("In func {funcname}:{location}:")]
21 InFunc {
22 funcname: &'static str,
23 location: &'static str,
24 #[source]
25 err: Box<GuestError>,
26 },
27 #[error("In data {typename}.{field}:")]
28 InDataField {
29 typename: String,
30 field: String,
31 #[source]
32 err: Box<GuestError>,
33 },
34 #[error("Invalid UTF-8 encountered: {0:?}")]
35 InvalidUtf8(#[from] ::std::str::Utf8Error),
36 #[error("Int conversion error: {0:?}")]
37 TryFromIntError(#[from] ::std::num::TryFromIntError),
38}