substrate/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum SubstrateError {
5    #[error("Memory protection failed: {0}")]
6    MemoryProtection(String),
7
8    #[error("Memory mapping failed: {0}")]
9    MemoryMap(String),
10
11    #[error("Invalid symbol address")]
12    InvalidSymbol,
13
14    #[error("Symbol not found: {0}")]
15    SymbolNotFound(String),
16
17    #[error("Library not found: {0}")]
18    LibraryNotFound(String),
19
20    #[error("ELF parsing error: {0}")]
21    ElfParsing(String),
22
23    #[error("Invalid instruction at {0:#x}")]
24    InvalidInstruction(usize),
25
26    #[error("Instruction disassembly failed")]
27    DisassemblyFailed,
28
29    #[error("Hook installation failed: {0}")]
30    HookFailed(String),
31
32    #[error("Insufficient space for hook")]
33    InsufficientSpace,
34
35    #[error("I/O error: {0}")]
36    Io(#[from] std::io::Error),
37
38    #[error("Null pointer encountered")]
39    NullPointer,
40
41    #[error("File not found: {0}")]
42    FileNotFound(String),
43
44    #[error("Parse error: {0}")]
45    ParseError(String),
46}
47
48pub type Result<T> = std::result::Result<T, SubstrateError>;