Skip to content

Commit

Permalink
fail nicely if %time col has gone missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dten committed Sep 9, 2023
1 parent e25381e commit dd38ed5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/collapse/ghcprof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ impl Collapse for Folder {
// - BUT it has a max width of 9 whilst its values can exceed (but are always space separted)
// "%time %alloc %time %alloc ticks bytes"
let source = match self.opt.source {
Source::PercentTime => l.find("%time").unwrap(),
Source::PercentTime => match l.find("%time") {
Some(col_start) => col_start,
_ => {
return invalid_data_error!(
"Expected '%time' column but it was not present"
)

Check warning on line 92 in src/collapse/ghcprof.rs

View check run for this annotation

Codecov / codecov/patch

src/collapse/ghcprof.rs#L90-L92

Added lines #L90 - L92 were not covered by tests
}
},
// See note above about ticks and bytes columns
Source::Ticks => one_off_end_of_col_before(l.as_ref(), "ticks")?,
Source::Bytes => one_off_end_of_col_before(l.as_ref(), "bytes")?,
Expand Down

0 comments on commit dd38ed5

Please sign in to comment.