procmem_linux/
error.rs

1use std::{io::Error, num::ParseIntError};
2
3use thiserror::Error;
4
5use crate::library::ParseLibraryError;
6
7/// errors relating to the process struct.
8#[derive(Error, Debug)]
9pub enum ProcessError {
10    #[error("the requested process could not be found")]
11    NotFound,
12    #[error("the pid of the requested process is not valid")]
13    InvalidPid(#[from] ParseIntError),
14    #[error("unable to parse library")]
15    InvalidLibrary(#[from] ParseLibraryError),
16    #[error("misc io error")]
17    Io(Error),
18}
19
20/// errors relating to memory reads/writes.
21#[derive(Error, Debug)]
22pub enum MemoryError {
23    #[error("the requested address is out of range")]
24    OutOfRange,
25    #[error("the process has quit")]
26    ProcessQuit,
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("string is not valid utf-8")]
36    InvalidString,
37    #[error("pattern was not found")]
38    NotFound,
39    #[error("misc io error")]
40    Io(#[from] Error),
41    #[error("unknown memory error")]
42    Unknown,
43}