From 1ae21a9a9ffdeea5f19fed9e2c5fcd2a4be34777 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 14 Sep 2021 14:29:38 +0200 Subject: [PATCH] Let file format error message mention that upgrading to newer version of measureme might help. + rustfmt --- analyzeme/src/file_formats/v7.rs | 4 +--- analyzeme/src/profiling_data.rs | 19 ++++++++++++------- decodeme/src/lib.rs | 6 +----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/analyzeme/src/file_formats/v7.rs b/analyzeme/src/file_formats/v7.rs index d2e9306..995853d 100644 --- a/analyzeme/src/file_formats/v7.rs +++ b/analyzeme/src/file_formats/v7.rs @@ -20,9 +20,7 @@ pub struct EventDecoder { } impl EventDecoder { - pub fn new( - entire_file_data: Vec, - ) -> Result> { + pub fn new(entire_file_data: Vec) -> Result> { let legacy_profiling_data = ProfilingData::from_paged_buffer(entire_file_data)?; let metadata = Metadata { diff --git a/analyzeme/src/profiling_data.rs b/analyzeme/src/profiling_data.rs index 778f0cb..0cf6404 100644 --- a/analyzeme/src/profiling_data.rs +++ b/analyzeme/src/profiling_data.rs @@ -61,18 +61,23 @@ impl ProfilingData { )?; let event_decoder: Box = match file_format_version { - file_formats::v7::FILE_FORMAT => Box::new(file_formats::v7::EventDecoder::new( - data - )?), + file_formats::v7::FILE_FORMAT => Box::new(file_formats::v7::EventDecoder::new(data)?), file_formats::v8::FILE_FORMAT => Box::new(file_formats::v8::EventDecoder::new( data, diagnostic_file_path, )?), unsupported_version => { - let msg = format!( - "File version {} is not support by this version of measureme.", - unsupported_version - ); + let msg = if unsupported_version > file_formats::current::FILE_FORMAT { + format!( + "File version {} is too new for this version of measureme. Try upgrading your tools to the latest version.", + unsupported_version + ) + } else { + format!( + "File version {} is too old to be supported by this version of measureme.", + unsupported_version + ) + }; return Err(From::from(msg)); } diff --git a/decodeme/src/lib.rs b/decodeme/src/lib.rs index 30c2316..8fddec1 100644 --- a/decodeme/src/lib.rs +++ b/decodeme/src/lib.rs @@ -9,11 +9,7 @@ use std::{ use event::Event; use event_payload::EventPayload; use lightweight_event::LightweightEvent; -use measureme::{ - file_header::{ - verify_file_header, FILE_MAGIC_EVENT_STREAM, - }, -}; +use measureme::file_header::{verify_file_header, FILE_MAGIC_EVENT_STREAM}; pub mod event; pub mod event_payload;