mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 14:57:32 -05:00
Return an error instead of exiting
This commit is contained in:
parent
de9a0ed522
commit
c2daad8340
1 changed files with 4 additions and 8 deletions
|
@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Display, Formatter};
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{self, BufRead, BufReader};
|
use std::io::{self, BufRead, BufReader};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{exit, Command, Output};
|
use std::process::{Command, Output};
|
||||||
use std::{array, mem};
|
use std::{array, mem};
|
||||||
use winnow::ascii::{space0, Caseless};
|
use winnow::ascii::{space0, Caseless};
|
||||||
use winnow::combinator::opt;
|
use winnow::combinator::opt;
|
||||||
|
@ -145,13 +145,9 @@ impl Exercise {
|
||||||
let mut line = String::with_capacity(256);
|
let mut line = String::with_capacity(256);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let n = read_line(&mut line).unwrap_or_else(|e| {
|
let n = read_line(&mut line).with_context(|| {
|
||||||
println!(
|
format!("Failed to read the exercise file {}", self.path.display())
|
||||||
"Failed to read the exercise file {}: {e}",
|
})?;
|
||||||
self.path.display(),
|
|
||||||
);
|
|
||||||
exit(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reached the end of the file and didn't find the comment.
|
// Reached the end of the file and didn't find the comment.
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
|
|
Loading…
Reference in a new issue