summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-07 01:15:47 +0200
committermo8it <mo8it@proton.me>2024-04-07 01:15:47 +0200
commitc2daad8340c04eaa84525f6ee832972667068fd6 (patch)
tree9cfa8d2b67d5d807c1dcf22c7a929b0f1c93e9b6 /src
parentde9a0ed5221934b43a27921455f484e006c3ec20 (diff)
Return an error instead of exiting
Diffstat (limited to 'src')
-rw-r--r--src/exercise.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/exercise.rs b/src/exercise.rs
index d5ca254..d01d427 100644
--- a/src/exercise.rs
+++ b/src/exercise.rs
@@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Display, Formatter};
use std::fs::{self, File};
use std::io::{self, BufRead, BufReader};
use std::path::PathBuf;
-use std::process::{exit, Command, Output};
+use std::process::{Command, Output};
use std::{array, mem};
use winnow::ascii::{space0, Caseless};
use winnow::combinator::opt;
@@ -145,13 +145,9 @@ impl Exercise {
let mut line = String::with_capacity(256);
loop {
- let n = read_line(&mut line).unwrap_or_else(|e| {
- println!(
- "Failed to read the exercise file {}: {e}",
- self.path.display(),
- );
- exit(1);
- });
+ let n = read_line(&mut line).with_context(|| {
+ format!("Failed to read the exercise file {}", self.path.display())
+ })?;
// Reached the end of the file and didn't find the comment.
if n == 0 {