-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Revise generate function to return Result #4430
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
base: main
Are you sure you want to change the base?
Revise generate function to return Result #4430
Conversation
…Add anyhow error handling. Revert expect call in generate API
ctest/src/lib.rs
Outdated
use std::collections::{HashMap, HashSet}; | ||
use std::env; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::io::BufWriter; | ||
use std::panic::{catch_unwind, AssertUnwindSafe}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we can't use catch_unwind
; if somebody has panic = abort
in their Cargo.toml or if run on a target/backend that doesn't support unwinding, the program will stop and catch_unwind
won't actually catch anything. All functions that may return an error need to change their signature then update .unwrap()
/ .expect()
to ?
.
Everything else looks pretty good to me, but I'll re-review after the changes.
(basically my same comment from #4424 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've removed the remaining catch_unwind
logic.
Description
As per #4369 , the generate function should return a Result instead of returning nothing.
This PR is a continuation of #4424 which was closed due to bad rebase.
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI