Skip to content

Commit

Permalink
add error handling to evtxls
Browse files Browse the repository at this point in the history
  • Loading branch information
janstarke committed Jul 29, 2024
1 parent f221893 commit de301d4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/bin/evtxls/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,18 @@ impl EvtxLs {
};

let mut records = Vec::new();
let mut handled_records = 0;
let mut expected_records: usize = 0;

for result in parser.records_json_value() {
expected_records += 1;
match result {
Err(_) => (),
Err(why) => {
log::error!("error while parsing a record; read {handled_records} until now. I'll try to continue with the next record");
log::warn!("{why}")
}
Ok(record) => {
handled_records += 1;
if let Some(not_before) = self.cli.not_before.as_ref() {
if &record.timestamp < not_before {
continue;
Expand Down Expand Up @@ -116,6 +123,10 @@ impl EvtxLs {
}
}

if handled_records < expected_records {
log::warn!("I expected {expected_records}, but only {handled_records} could be handled.")
}

Ok(records)
}

Expand Down

0 comments on commit de301d4

Please sign in to comment.