From dd38ed585ffcc5eb091dd25244c461f03da4b138 Mon Sep 17 00:00:00 2001 From: David Hewson Date: Sat, 9 Sep 2023 18:56:10 +0100 Subject: [PATCH] fail nicely if %time col has gone missing --- src/collapse/ghcprof.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/collapse/ghcprof.rs b/src/collapse/ghcprof.rs index da8489bb..6977e065 100644 --- a/src/collapse/ghcprof.rs +++ b/src/collapse/ghcprof.rs @@ -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" + ) + } + }, // 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")?,