Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added expect error message to TimeFeedback where there used to be an unwrap #2777

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AshrafIbrahim03
Copy link

I encountered this unwrap while writing a fuzzer. If the observer referenced by a TimeFeedback isn't in the fuzzer, then this unwrap is triggered with no helpful error message. I put down Observer referenced by TimeFeedback is not found in observers given to the fuzzer as the error message when this is hit.

@tokatoka
Copy link
Member

can you run cargo fmt?

@@ -940,7 +940,7 @@ where
observers: &OT,
testcase: &mut Testcase<I>,
) -> Result<(), Error> {
let observer = observers.get(&self.observer_handle).unwrap();
let observer = observers.get(&self.observer_handle).expect("Observer referenced by TimeFeedback is not found in observers given to the fuzzer");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right way here would be to return Err(Error::illegal_state("Observer referenced by TimeFeedback is not found in observers given to the fuzzer"))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And anyway this should never happen, how did you reach this state?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reached it because I didn't give the fuzzer all my observers. I got confused when it just hit the unwrap, so then I made the PR.

@domenukk
Copy link
Member

Can you run cargo fmt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants