nyx_lite/
error.rs

1use thiserror::Error;
2use vmm::vstate::memory::GuestAddress;
3
4#[derive(Error, Debug)]
5pub enum NyxError {
6    #[error("Failed Memory Operation")]
7    Memory(MemoryError),
8    //#[error("the data for key `{0}` is not available")]
9    //Redaction(String),
10    //#[error("invalid header (expected {expected:?}, found {found:?})")]
11    //InvalidHeader {
12    //    expected: String,
13    //    found: String,
14    //},
15    //#[error("unknown data store error")]
16    //Unknown,
17}
18
19#[derive(Error, Debug, PartialEq, Eq)]
20pub enum MemoryError {
21    #[error("could not read from p:{:x}", (.0).0)]
22    CantAccessMissingPhysicalPage(GuestAddress),
23    #[error("could not read from p:{:x} (size: {})", (.0).0, .1)]
24    CantReadPhysicalPage(GuestAddress, usize),
25    #[error("could not write to p:{:x} (size: {})", (.0).0, .1)]
26    CantWritePhysicalPage(GuestAddress, usize),
27    #[error("page at page_table p:{:x}:{} is not present", (.0).0 ,.1)]
28    PageNotPresent(GuestAddress, u64),
29    #[error("unaligned address: {0:#x}")]
30    UnalignedAddress(u64),
31    #[error("missing page table for vaddr: {0:#x}")]
32    MissingPageTable(u64),
33    #[error("unable to allocate page table for vaddr: {0:#x}")]
34    PageTableAllocationFailed(u64),
35}