procmem_linux/
error.rs

1use std::num::IntErrorKind;
2
3use thiserror::Error;
4
5/// errors relating to the process struct.
6#[derive(Error, Debug)]
7pub enum ProcessError {
8    #[error("the requested process could not be found")]
9    NotFound,
10    #[error("the pid of the requested process is not valid")]
11    InvalidPid(IntErrorKind),
12    #[error("permission to open /proc/{0}/mem was denied")]
13    PermissionDenied(i32),
14    #[error("failed to open /proc/{0}/mem")]
15    FileOpenError(i32),
16}
17
18/// errors relating to memory reads/writes.
19#[derive(Error, Debug)]
20pub enum MemoryError {
21    #[error("the requested address is out of range")]
22    OutOfRange,
23    #[error("the process has quit")]
24    ProcessQuit,
25    #[error("permission to memory was denied")]
26    PermissionDenied,
27    #[error("data could not be parsed to type {0}")]
28    InvalidData(&'static str),
29    #[error("only {0} out of {1} bytes could be transferred")]
30    PartialTransfer(usize, usize),
31    #[error("library at given address is not valid")]
32    InvalidLibrary,
33    #[error("c-style string was too long")]
34    StringTooLong,
35    #[error("pattern was not found")]
36    NotFound,
37    #[error("unknown read error")]
38    Unknown,
39}