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
|
/// Gets the next entry
|
||||||
fn get(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
fn get(&mut self) -> Result<&Box<dyn Testcase>, AflError> {
|
||||||
if self.count() == 0 {
|
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;
|
self.pos = self.pos + 1;
|
||||||
if self.pos >= self.count() {
|
if self.pos >= self.count() {
|
||||||
@ -156,7 +156,7 @@ pub struct SimpleTestcase {
|
|||||||
impl Testcase for SimpleTestcase {
|
impl Testcase for SimpleTestcase {
|
||||||
fn load_input(&mut self) -> Result<&Box<dyn Input>, AflError> {
|
fn load_input(&mut self) -> Result<&Box<dyn Input>, AflError> {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
Err(AflError::Unknown)
|
Err(AflError::NotImplemented("load_input".to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_on_disk(&self) -> bool {
|
fn is_on_disk(&self) -> bool {
|
||||||
|
@ -124,7 +124,7 @@ impl Executor for InMemoryExecutor {
|
|||||||
fn run_target(&mut self) -> Result<ExitKind, AflError> {
|
fn run_target(&mut self) -> Result<ExitKind, AflError> {
|
||||||
let bytes = match self.base.cur_input.as_ref() {
|
let bytes = match self.base.cur_input.as_ref() {
|
||||||
Some(i) => i.serialize(),
|
Some(i) => i.serialize(),
|
||||||
None => return Err(AflError::Unknown),
|
None => return Err(AflError::Empty("cur_input".to_string())),
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
CURRENT_INMEMORY_EXECUTOR_PTR = self as *const InMemoryExecutor;
|
CURRENT_INMEMORY_EXECUTOR_PTR = self as *const InMemoryExecutor;
|
||||||
@ -203,10 +203,10 @@ mod tests {
|
|||||||
|
|
||||||
impl Observer for Nopserver {
|
impl Observer for Nopserver {
|
||||||
fn reset(&mut self) -> Result<(), AflError> {
|
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> {
|
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 {
|
fn as_any(&self) -> &dyn Any {
|
||||||
|
@ -20,8 +20,12 @@ pub enum AflError {
|
|||||||
File(#[from] io::Error),
|
File(#[from] io::Error),
|
||||||
#[error("Key `{0}` not in Corpus")]
|
#[error("Key `{0}` not in Corpus")]
|
||||||
KeyNotFound(String),
|
KeyNotFound(String),
|
||||||
#[error("Unknown error")]
|
#[error("No items in {0}")]
|
||||||
Unknown,
|
Empty(String),
|
||||||
|
#[error("Not implemented: {0}")]
|
||||||
|
NotImplemented(String),
|
||||||
|
#[error("Unknown error: {0}")]
|
||||||
|
Unknown(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -10,7 +10,7 @@ impl Stage for MutationalStage {
|
|||||||
|
|
||||||
fn Perform(&mut self, input: &Input, entry: &mut Entry) -> Result<(), AflError> {
|
fn Perform(&mut self, input: &Input, entry: &mut Entry) -> Result<(), AflError> {
|
||||||
// TODO: Implement me
|
// TODO: Implement me
|
||||||
Err(AflError::Unknown);
|
Err(AflError::NotImplemented("Stage does not perform yet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user