Skip to content

Commit

Permalink
Let file format error message mention that upgrading to newer version
Browse files Browse the repository at this point in the history
of measureme might help.

+ rustfmt
  • Loading branch information
michaelwoerister committed Sep 14, 2021
1 parent ac60c6b commit 1ae21a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 1 addition & 3 deletions analyzeme/src/file_formats/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ pub struct EventDecoder {
}

impl EventDecoder {
pub fn new(
entire_file_data: Vec<u8>,
) -> Result<EventDecoder, Box<dyn Error + Send + Sync>> {
pub fn new(entire_file_data: Vec<u8>) -> Result<EventDecoder, Box<dyn Error + Send + Sync>> {
let legacy_profiling_data = ProfilingData::from_paged_buffer(entire_file_data)?;

let metadata = Metadata {
Expand Down
19 changes: 12 additions & 7 deletions analyzeme/src/profiling_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,23 @@ impl ProfilingData {
)?;

let event_decoder: Box<dyn file_formats::EventDecoder> = 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));
}
Expand Down
6 changes: 1 addition & 5 deletions decodeme/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1ae21a9

Please sign in to comment.