From 28fdc282fcc76a1bf8ef4056e3f46bf3f17ba768 Mon Sep 17 00:00:00 2001 From: 20urc3 <94982366+20urc3@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:46:43 +0100 Subject: [PATCH] Update lib.rs I added the new error variants to the Error enum: - Configuration - For errors related to incorrect configuration settings - Compilation - For errors related to code compilation issues - System - For system call failures and resource allocation problems - Version - For version compatibility issues and added their corresponding constructor methods for each new error type, following the same pattern as the existing constructors in the library. --- libafl_bolts/src/lib.rs | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/libafl_bolts/src/lib.rs b/libafl_bolts/src/lib.rs index e41ad4715c1..e8ca089f615 100644 --- a/libafl_bolts/src/lib.rs +++ b/libafl_bolts/src/lib.rs @@ -341,6 +341,14 @@ pub enum Error { InvalidCorpus(String, ErrorBacktrace), /// Error specific to a runtime like QEMU or Frida Runtime(String, ErrorBacktrace), + /// Configuration errors, such as incorrect map sizes + Configuration(String, ErrorBacktrace), + /// Compilation-related errors + Compilation(String, ErrorBacktrace), + /// System call or resource allocation failures + System(String, ErrorBacktrace), + /// Version compatibility issues + Version(String, ErrorBacktrace), } impl Error { @@ -497,6 +505,42 @@ impl Error { { Error::Runtime(arg.into(), ErrorBacktrace::new()) } + + /// Create a new configuration error + #[must_use] + pub fn configuration(msg: S) -> Self + where + S: Into, + { + Self::Configuration(msg.into(), ErrorBacktrace::new()) + } + + /// Create a new compilation error + #[must_use] + pub fn compilation(msg: S) -> Self + where + S: Into, + { + Self::Compilation(msg.into(), ErrorBacktrace::new()) + } + + /// Create a new system error + #[must_use] + pub fn system(msg: S) -> Self + where + S: Into, + { + Self::System(msg.into(), ErrorBacktrace::new()) + } + + /// Create a new version error + #[must_use] + pub fn version(msg: S) -> Self + where + S: Into, + { + Self::Version(msg.into(), ErrorBacktrace::new()) + } } impl core::error::Error for Error {