mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-18 06:58:10 -05:00
Use anyhow!
This commit is contained in:
parent
13cc3acdfd
commit
8854f0a5ed
1 changed files with 4 additions and 8 deletions
|
@ -229,7 +229,6 @@ fn check_exercises(info_file: &InfoFile, cmd_runner: &CmdRunner) -> Result<()> {
|
||||||
|
|
||||||
enum SolutionCheck {
|
enum SolutionCheck {
|
||||||
Success { sol_path: String },
|
Success { sol_path: String },
|
||||||
MissingRequired,
|
|
||||||
MissingOptional,
|
MissingOptional,
|
||||||
RunFailure { output: Vec<u8> },
|
RunFailure { output: Vec<u8> },
|
||||||
Err(Error),
|
Err(Error),
|
||||||
|
@ -252,7 +251,10 @@ fn check_solutions(
|
||||||
let sol_path = exercise_info.sol_path();
|
let sol_path = exercise_info.sol_path();
|
||||||
if !Path::new(&sol_path).exists() {
|
if !Path::new(&sol_path).exists() {
|
||||||
if require_solutions {
|
if require_solutions {
|
||||||
return SolutionCheck::MissingRequired;
|
return SolutionCheck::Err(anyhow!(
|
||||||
|
"The solution of the exercise {} is missing",
|
||||||
|
exercise_info.name,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SolutionCheck::MissingOptional;
|
return SolutionCheck::MissingOptional;
|
||||||
|
@ -296,12 +298,6 @@ fn check_solutions(
|
||||||
fmt_cmd.arg(&sol_path);
|
fmt_cmd.arg(&sol_path);
|
||||||
sol_paths.insert(PathBuf::from(sol_path));
|
sol_paths.insert(PathBuf::from(sol_path));
|
||||||
}
|
}
|
||||||
SolutionCheck::MissingRequired => {
|
|
||||||
bail!(
|
|
||||||
"The solution of the exercise {} is missing",
|
|
||||||
exercise_info.name,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
SolutionCheck::MissingOptional => (),
|
SolutionCheck::MissingOptional => (),
|
||||||
SolutionCheck::RunFailure { output } => {
|
SolutionCheck::RunFailure { output } => {
|
||||||
stdout.write_all(b"\n\n")?;
|
stdout.write_all(b"\n\n")?;
|
||||||
|
|
Loading…
Reference in a new issue