error handling
This commit is contained in:
parent
dce4783eb0
commit
1fc5f1d6e5
@ -117,7 +117,7 @@ impl<RandT: Rand> Corpus for QueueCorpus<'_, RandT> {
|
||||
/// Gets the next entry
|
||||
fn get(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
||||
if self.count() == 0 {
|
||||
return Err(AflError::Unknown); // TODO(andrea) why unknown? use EmptyContainerError or similar
|
||||
return Err(AflError::Empty("Testcases".to_string()));
|
||||
}
|
||||
self.pos = self.pos + 1;
|
||||
if self.pos >= self.count() {
|
||||
@ -156,7 +156,7 @@ pub struct SimpleTestcase {
|
||||
impl Testcase for SimpleTestcase {
|
||||
fn load_input(&mut self) -> Result<&Box<dyn Input>, AflError> {
|
||||
// TODO: Implement
|
||||
Err(AflError::Unknown)
|
||||
Err(AflError::NotImplemented("load_input".to_string()))
|
||||
}
|
||||
|
||||
fn is_on_disk(&self) -> bool {
|
||||
|
@ -124,7 +124,7 @@ impl Executor for InMemoryExecutor {
|
||||
fn run_target(&mut self) -> Result<ExitKind, AflError> {
|
||||
let bytes = match self.base.cur_input.as_ref() {
|
||||
Some(i) => i.serialize(),
|
||||
None => return Err(AflError::Unknown),
|
||||
None => return Err(AflError::Empty("cur_input".to_string())),
|
||||
};
|
||||
unsafe {
|
||||
CURRENT_INMEMORY_EXECUTOR_PTR = self as *const InMemoryExecutor;
|
||||
@ -203,10 +203,10 @@ mod tests {
|
||||
|
||||
impl Observer for Nopserver {
|
||||
fn reset(&mut self) -> Result<(), AflError> {
|
||||
Err(AflError::Unknown)
|
||||
Err(AflError::Unknown("Nop reset, testing only".to_string()))
|
||||
}
|
||||
fn post_exec(&mut self) -> Result<(), AflError> {
|
||||
Err(AflError::Unknown)
|
||||
Err(AflError::Unknown("Nop exec, testing only".to_string()))
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
|
10
src/lib.rs
10
src/lib.rs
@ -20,9 +20,13 @@ pub enum AflError {
|
||||
File(#[from] io::Error),
|
||||
#[error("Key `{0}` not in Corpus")]
|
||||
KeyNotFound(String),
|
||||
#[error("Unknown error")]
|
||||
Unknown,
|
||||
}
|
||||
#[error("No items in {0}")]
|
||||
Empty(String),
|
||||
#[error("Not implemented: {0}")]
|
||||
NotImplemented(String),
|
||||
#[error("Unknown error: {0}")]
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -10,7 +10,7 @@ impl Stage for MutationalStage {
|
||||
|
||||
fn Perform(&mut self, input: &Input, entry: &mut Entry) -> Result<(), AflError> {
|
||||
// TODO: Implement me
|
||||
Err(AflError::Unknown);
|
||||
Err(AflError::NotImplemented("Stage does not perform yet"));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user