From b991249a88528041fdfadd7bd384c96a8b5112e6 Mon Sep 17 00:00:00 2001 From: Laszlo Nagy Date: Thu, 26 Sep 2024 12:16:39 +0000 Subject: [PATCH] rust: event reader error message revisited --- rust/bear/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/bear/src/main.rs b/rust/bear/src/main.rs index 60460179..55744ab7 100644 --- a/rust/bear/src/main.rs +++ b/rust/bear/src/main.rs @@ -173,10 +173,12 @@ impl Application { semantic_transform, output_writer, } => { + // Set up the pipeline of compilation database entries. let entries = event_source .generate() .flat_map(|execution| semantic_recognition.recognize(execution)) .flat_map(|semantic| semantic_transform.into_entries(semantic)); + // Consume the entries and write them to the output file. // The exit code is based on the result of the output writer. match output_writer.run(entries) { Ok(_) => ExitCode::SUCCESS, @@ -202,7 +204,6 @@ impl Application { /// Here we only handle the file opening and the error handling. struct EventFileReader { reader: BufReader, - file_name: PathBuf, } impl TryFrom for EventFileReader { @@ -216,10 +217,10 @@ impl TryFrom for EventFileReader { let file = OpenOptions::new() .read(true) .open(file_name.as_path()) - .with_context(|| format!("Failed to open file: {:?}", file_name))?; + .with_context(|| format!("Failed to open input file: {:?}", file_name))?; let reader = BufReader::new(file); - Ok(EventFileReader { reader, file_name }) + Ok(EventFileReader { reader }) } } @@ -235,8 +236,7 @@ impl EventFileReader { .flat_map(|candidate| match candidate { Ok(execution) => Some(execution), Err(error) => { - // FIXME: write the file name to the log. - log::warn!("Failed to read entry: {}", error); + log::warn!("Failed to read entry from input: {}", error); None } })