Better error message instead of "No entries in corpus"

This commit is contained in:
Dongjia "toka" Zhang 2024-03-15 19:19:55 +01:00 committed by GitHub
parent c6875b8cf6
commit 34b4a6ac1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 6 deletions

View File

@ -300,7 +300,7 @@ where
/// Gets the next entry at random /// Gets the next entry at random
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> { fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
if state.corpus().count() == 0 { if state.corpus().count() == 0 {
Err(Error::empty("No entries in corpus".to_owned())) Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned()))
} else { } else {
let id = random_corpus_id!(state.corpus(), state.rand_mut()); let id = random_corpus_id!(state.corpus(), state.rand_mut());
self.set_current_scheduled(state, Some(id))?; self.set_current_scheduled(state, Some(id))?;

View File

@ -259,7 +259,7 @@ where
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> { fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
if state.corpus().count() == 0 { if state.corpus().count() == 0 {
Err(Error::empty(String::from("No entries in corpus"))) Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented.")))
} else { } else {
let id = match state.corpus().current() { let id = match state.corpus().current() {
Some(cur) => { Some(cur) => {

View File

@ -158,7 +158,7 @@ where
#[allow(clippy::cast_precision_loss)] #[allow(clippy::cast_precision_loss)]
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> { fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
if state.corpus().count() == 0 { if state.corpus().count() == 0 {
Err(Error::empty(String::from("No entries in corpus"))) Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented.")))
} else { } else {
let rand_prob: f64 = (state.rand_mut().below(100) as f64) / 100.0; let rand_prob: f64 = (state.rand_mut().below(100) as f64) / 100.0;
let meta = state.metadata_map().get::<ProbabilityMetadata>().unwrap(); let meta = state.metadata_map().get::<ProbabilityMetadata>().unwrap();

View File

@ -44,7 +44,7 @@ where
/// Gets the next entry in the queue /// Gets the next entry in the queue
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> { fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
if state.corpus().count() == 0 { if state.corpus().count() == 0 {
Err(Error::empty("No entries in corpus".to_owned())) Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned()))
} else { } else {
let id = state let id = state
.corpus() .corpus()

View File

@ -119,7 +119,7 @@ where
/// Gets the next entry in the queue /// Gets the next entry in the queue
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> { fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
if state.corpus().count() == 0 { if state.corpus().count() == 0 {
return Err(Error::empty("No entries in corpus".to_owned())); return Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned()));
} }
let id = if let Some(next) = Self::get_next(state) { let id = if let Some(next) = Self::get_next(state) {
// next was set // next was set

View File

@ -303,7 +303,7 @@ where
fn next(&mut self, state: &mut S) -> Result<CorpusId, Error> { fn next(&mut self, state: &mut S) -> Result<CorpusId, Error> {
let corpus_counts = state.corpus().count(); let corpus_counts = state.corpus().count();
if corpus_counts == 0 { if corpus_counts == 0 {
Err(Error::empty(String::from("No entries in corpus"))) Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented.")))
} else { } else {
let s = random_corpus_id!(state.corpus(), state.rand_mut()); let s = random_corpus_id!(state.corpus(), state.rand_mut());