moco_vm/error.rs
1use core::{
2 error,
3 fmt::{self, Debug, Display, Formatter},
4};
5
6/// An error of a virtual machine.
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum Error {
9 /// Invalid memory access.
10 InvalidMemoryAccess,
11 /// Out of memory.
12 OutOfMemory,
13}
14
15impl error::Error for Error {}
16
17impl Display for Error {
18 fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
19 match self {
20 Self::InvalidMemoryAccess => write!(formatter, "invalid memory access"),
21 Self::OutOfMemory => write!(formatter, "out of memory"),
22 }
23 }
24}