add structured error handling with thiserror
This commit is contained in:
27
ghost-core/src/error.rs
Normal file
27
ghost-core/src/error.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum GhostError {
|
||||
#[error("Process access denied (PID: {pid})")]
|
||||
AccessDenied { pid: u32 },
|
||||
|
||||
#[error("Process not found (PID: {pid})")]
|
||||
ProcessNotFound { pid: u32 },
|
||||
|
||||
#[error("Memory enumeration failed: {reason}")]
|
||||
MemoryEnumeration { reason: String },
|
||||
|
||||
#[error("Thread enumeration failed: {reason}")]
|
||||
ThreadEnumeration { reason: String },
|
||||
|
||||
#[error("Insufficient privileges for operation")]
|
||||
InsufficientPrivileges,
|
||||
|
||||
#[error("Windows API error: {message}")]
|
||||
WindowsApi { message: String },
|
||||
|
||||
#[error("Detection engine error: {message}")]
|
||||
Detection { message: String },
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, GhostError>;
|
||||
@@ -1,9 +1,11 @@
|
||||
pub mod detection;
|
||||
pub mod error;
|
||||
pub mod memory;
|
||||
pub mod process;
|
||||
pub mod thread;
|
||||
|
||||
pub use detection::{DetectionEngine, DetectionResult, ThreatLevel};
|
||||
pub use error::{GhostError, Result};
|
||||
pub use memory::{MemoryProtection, MemoryRegion};
|
||||
pub use process::ProcessInfo;
|
||||
pub use thread::ThreadInfo;
|
||||
|
||||
Reference in New Issue
Block a user