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

[WIP] Expand error handling support #58

Closed

Conversation

chrissimpkins
Copy link
Member

@chrissimpkins chrissimpkins commented Feb 22, 2020

This PR refactors existing custom errors to a new errors.rs module and replaces panics with error handling support across all source files.

WIP => Result return types were added across all functions that raise errors; however, I need input on how to work the error handling through the least_satisfying closures in:

cargo-bisect-rustc/src/main.rs

Lines 1249 to 1270 in 7ac0397

let found = least_satisfying(&toolchains, |t| {
match t.install(&client, &dl_spec) {
Ok(()) => {
let outcome = t.test(&cfg);
// we want to fail, so a successful build doesn't satisfy us
let r = match outcome {
TestOutcome::Baseline => Satisfies::No,
TestOutcome::Regressed => Satisfies::Yes,
};
if !cfg.args.preserve {
let _ = t.remove(&dl_spec);
}
eprintln!("tested {}, got {}", t, r);
r
}
Err(err) => {
let _ = t.remove(&dl_spec);
eprintln!("failed to install {}: {:?}", t, err);
Satisfies::Unknown
}
}
});

and

cargo-bisect-rustc/src/main.rs

Lines 1360 to 1383 in 7ac0397

let found = least_satisfying(&toolchains, |t| {
eprintln!("installing {}", t);
match t.install(&client, &dl_spec) {
Ok(()) => {
eprintln!("testing {}", t);
let outcome = t.test(&cfg);
// we want to fail, so a successful build doesn't satisfy us
let r = match outcome {
TestOutcome::Regressed => Satisfies::Yes,
TestOutcome::Baseline => Satisfies::No,
};
eprintln!("tested {}, got {}", t, r);
if !cfg.args.preserve {
let _ = t.remove(&dl_spec);
}
r
}
Err(err) => {
let _ = t.remove(&dl_spec);
eprintln!("failed to install {}: {:?}", t, err);
Satisfies::Unknown
}
}
});

At the moment, the errors raised in the Toolchain.test method will still panic during the least_satisfying tests.

Fixes #16
Supersedes #48


TODO

  • eliminate panics in the least_satisfying part of bisect_nightlies
  • eliminate panics in the least_satisfying part of bisect_ci_between

impl FromStr for Bound {
type Err = BoundParseError;
fn from_str(s: &str) -> Result<Bound, BoundParseError> {
type Err = NeverError;
Copy link
Member Author

Choose a reason for hiding this comment

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

requires feedback

Is this a necessary error? I renamed it to make it a more general error type, but I think that it can be eliminated altogether?

let outcome = t.test(&cfg);
// TODO (@chrissimpkins): handle errors in this closure through least_satisfying
// This line will still panic on calls to Toolchain.test
let outcome = t.test(&cfg).unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

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

need help here

Site of a TODO for least_satisfying function associated error handling

let outcome = t.test(&cfg);
// TODO (@chrissimpkins): handle errors in this closure through least_satisfying
// This line will still panic on calls to Toolchain.test
let outcome = t.test(&cfg).unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

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

need help here

Site of a TODO for least_satisfying function associated error handling

@@ -1398,10 +1368,10 @@ struct BisectionResult {

fn main() {
if let Err(err) = run() {
match err.downcast::<ExitError>() {
Ok(ExitError(code)) => process::exit(code),
match err.downcast::<ExitStatusError>() {
Copy link
Member Author

Choose a reason for hiding this comment

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

requires feedback

The ExitError was in main and I simply renamed it to make it clear that this is the approach to explicitly define an exit status code number. It does not appear to be in use any longer. Maybe we just eliminate it?

@chrissimpkins
Copy link
Member Author

Will rebase on the #57 merge if there is interest in this approach

@chrissimpkins
Copy link
Member Author

Is there any interest in supporting this?

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.

panic, when selecting mark baseline two times
1 participant